Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
snehamahaveer
Creator
Creator

Unable to run a macro

Hi everyone, I was currently working on a project which required all charts and tables to be extracted to a single excel file with charts on first page and tables on the next. Before I start for the bigger fish I tried with a trial version of a simpler script. The script is as follows:- Function ExportCharts()  Set xlApp = CreateObject("Excel.Application")  xlApp.Visible = true  Set xlDoc = xlApp.Workbooks.Add 'open new workbook    nSheetsCount = 0    CALL RemoveDefaultSheet(xlDoc)      nSheetsCount = xlDoc.Sheets.Count    xlDoc.Sheets(nSheetsCount).Select    Set xlSheet = xlDoc.Sheets(nSheetsCount)      CALL ExportRevenueWidgets(xlDoc,xlSheet)  End Function  'Call Export Widgets By Sheet  Function ExportRevenueWidgets(xlDoc,xlSheet)    CALL Export(xlDoc,xlSheet,"CH03", "A")    CALL Export(xlDoc,xlSheet,"CH07", "D")    CALL Export(xlDoc,xlSheet,"CHO8", "B")   CALL Export(xlDoc,xlSheet,"CH09", "C")   CALL Export(xlDoc,xlSheet,"CH13", "E")   CALL Export(xlDoc,xlSheet,"CH07", "F") End Function    'Export Widgets  Function Export(xlDoc, xlSheet,widgetID, columnStart)      nRow = xlSheet.UsedRange.Rows.Count      nRow = 1    Set SheetObj = ActiveDocument.GetSheetObject(widgetID)      'Copy the chart object to clipboard    SheetObj.CopyTableToClipboard true      'Paste the chart object in Excel file    xlSheet.Paste xlSheet.Range(columnStart&nRow)  End Function    'Remove Default Sheets from Excel Files  Sub RemoveDefaultSheet(xlDoc)    Do    nSheetsCount = xlDoc.Sheets.Count    If nSheetsCount = 1 then    Exit Do    Else    xlDoc.Sheets(nSheetsCount).Select    xlDoc.ActiveSheet.Delete    End If    Loop  End Sub  If someone could point my mistake it would be fantastic. Thanks in advance.

1 Reply