Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Karim_Khan
Creator III
Creator III

Macro not working for multiple object

Hi All,

     I am creating the macro first time to export the objects from qlik to excel.it's working fine for exporting one chart to excel but whenever m trying to export multiple objects into multiple sheet with different sheet name it's throwing an error  ScriptOut of range



sub ExcelFile


  strDate = CDate(Date)

  strDay = DatePart("d", strDate)

  strMonth = DatePart("m", strDate)

  strYear = DatePart("yyyy", strDate)

  If strDay < 10 Then

    strDay = "0" & strDay

  End If

  If strMonth < 10 Then

    strMonth = "0" & strMonth

  End If

  GetFormattedDate = strMonth & "-" & strDay & "-" & strYear

 

Path = "C:\temp\"

FileName = "Test_" & GetFormattedDate  & ".xlsx"


set XLApp = CreateObject("Excel.Application")


XLApp.Visible = true

set XLDoc = XLApp.Workbooks.Add(1)

ActiveDocument.GetSheetObject("Page One").CopyTableToClipboard true

XLDoc.Sheets(1).Paste()


XLDoc.Sheets(1).Rows("1:3000").EntireRow.AutoFit

ActiveDocument.GetSheetObject("Page Two").CopyTableToClipboard true

XLDoc.Sheets(2).Paste()    --------Throwing error at this line


XLDoc.Sheets(2).Rows("1:3000").EntireRow.AutoFit

XLDoc.Sheets(1).Name = "Page One"

XLDoc.Sheets(2).Name = "Page Two"

XLDoc.Sheets(3).Delete

XLDoc.Sheets(1).Range("A1").Select


end sub

Regards,

Karim Khan

KK
0 Replies