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: 
jakob_hansen
Partner - Contributor
Partner - Contributor

Export macro fails

When I run this macro the line "obj.Export "C:\test\Test2.csv", "," , , False" fails. Someone know why?

sub Export

ActiveDocument.ClearAll True

set Obj = ActiveDocument.GetSheetObject("CH14")

obj.Export "C:\test\Test2.csv", "," , , False

ActiveDocument.reload

end sub



1 Reply
raghavsurya
Partner - Specialist
Partner - Specialist

Hi Jakob,

Please find below one of the macros I got it from community posts.... which works perfectly for me.

Sub TestIt
SheetIt "C:\Users\raghavendra.s\Desktop\test.xls","OldSheetname","TB01","NewSheetname"
End sub

function SheetIt(ExcelDoc,SheetName,ChartName,Category)
set XLS = createobject("Excel.Application")
XLS.Visible = True
Set Workbook = XLS.Workbooks.Open(ExcelDoc)
Set Worksheet = Worksheets.xls(NewSheetname)
Worksheet.Activate
set obj = ActiveDocument.getsheetobject(TB01)
obj.CopyTableToClipboard true
Worksheet.paste
Worksheet.cells.select
Worksheet.cells.mergecells = false
Worksheet.Cells.EntireRow.RowHeight = 12.75
Worksheet.Cells.EntireColumn.AutoFit
Worksheet.name = Category
end function

Hope this helps.

Regards,

Raghav