Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

VB Macro to Export Table to CSV with No headers !

Hi - Can anyone help ?

I have the following vb macro that exports data to a csv file :

Sub ExportToFile

'Download Sheet ojbect data to CSV

set sObject = ActiveDocument.GetSheetObject("TB01")

sObject.Export "C:\download\BIB\TestFile.csv", ", "

End Sub

Works perfectly except I don't want the field headers.

After reading a few articles one work around is to kick of a bat file that contains:

TestFile.csv | find /V "Sort Code,Account Name,Account Number,Amount,Reference,BACS CODE" > noheader.csv

However this just leaves a blank file.

Does anyone have a solution ?????

1 Solution

Accepted Solutions
Not applicable
Author

For reference - the only way I could make it work was to export the csv file then kick off a bat file to remove the header. If interested my macro was as follows:

Sub ExportToFile

'Download Sheet ojbect data to CSV

set sObject = ActiveDocument.GetSheetObject("TB01")

sObject.Export "C:\download\BIB\TestFile.csv", ", "

'Run Bat File to remove headers

Dim obj

Set obj = CreateObject("WScript.Shell")

obj.Run "C:\download\BIB\test.bat ", , TRUE

End Sub

Then the script in the BAT file kicks off another bit of script. BAT file content is as follows :

c:\download\BIB\DeleteFirstLine.vbs "c:\download\BIB\TestFile.csv"

And the vbs file is attached:

(A bit long winded but it worked)

View solution in original post

5 Replies
isaiah82
Creator III
Creator III

I don't believe there is an option with the API to exclude header rows on export.  I notice that, even if you check the "Supress Header Row" on chart properties, the header row still exists on export.

Your batch command should work; it looks like maybe you're missing "type" command in front of the command in your post.  Also, the string following the /v must be perfect with case, spacing etc.

type TestFile.csv | find /V "Sort Code,Account Name,Account Number,Amount,Reference,BACS CODE" > noheader.csv

-Isaiah

Not applicable
Author

For reference - the only way I could make it work was to export the csv file then kick off a bat file to remove the header. If interested my macro was as follows:

Sub ExportToFile

'Download Sheet ojbect data to CSV

set sObject = ActiveDocument.GetSheetObject("TB01")

sObject.Export "C:\download\BIB\TestFile.csv", ", "

'Run Bat File to remove headers

Dim obj

Set obj = CreateObject("WScript.Shell")

obj.Run "C:\download\BIB\test.bat ", , TRUE

End Sub

Then the script in the BAT file kicks off another bit of script. BAT file content is as follows :

c:\download\BIB\DeleteFirstLine.vbs "c:\download\BIB\TestFile.csv"

And the vbs file is attached:

(A bit long winded but it worked)

Not applicable
Author

hi, the above vbs is not working for me. When I run the Macro my Wscript shell is not working

Not applicable
Author

Hi ,

Is there any way to add 2 rows in the top of the header for this same example

thnx

Not applicable
Author

This Solution works Great!