Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi!
i'm using the below macro to export a qv table into a csv file:
set ExportObject = ActiveDocument.GetSheetObject("CH1011")
ExportObject.Export "QV\Production\QVD\Monitor\Details.csv", ","
in the table I export (CH1011) there are 5 colums:
id, name, city, country, region
I only want to export the id, city and region columns. how can I do that?
thanks!
You create a copy of your pivot/table chart and leave only the columns you need. Export this copy..
Move it to a hidden sheet if you don't want to show it.
Hi Naamamor,
Try this code,
Sub Test
Dim objExcel
FileName = "QV\Production\QVD\Monitor\Details.csv"
set ExportObject = ActiveDocument.GetSheetObject("CH1011")
ExportObject.Export FileName, ","
Set XLApp = CreateObject("Excel.Application")
XLApp.Visible = False
XLApp.Workbooks.Open(FileName)
set XLSheet = XLApp.Worksheets(1)
XLSheet.Range("C:D").Delete
XLApp.DisplayAlerts = False
XLSheet.Saveas FileName
XLApp.DisplayAlerts = True
XLApp.Application.quit
set ExportObject = Nothiing
set XLSheet = Nothing
set XLApp = Nothing
Msgbox "Exported Sucessfully"
End Sub
Sorry. The correct column reference should be
XLSheet.Range("C:D").Delete
XLSheet.Range("B:B,D:D").Delete
thank you Tamil,
i receive this error msg: ActiveX component can't create object: 'Excel.Application'
Either macro settings are not set to System Access or Excel isn't installed on the computer.
He is using WebView and macros that uses CreateObject will not work there. Regardless security settings.
Use your current solution but create another object with only the dimension needed. As Lucian recommended.
Naamamor,
As suggested by mwoolf, you must set the requested module security and current local security to "Allow System Access" in macro window.
Hi ,
Could you please help me with a macro to export object data into .csv ?
Regards,
Hitha Dhani