Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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 ?????
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)
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
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)
hi, the above vbs is not working for me. When I run the Macro my Wscript shell is not working
Hi ,
Is there any way to add 2 rows in the top of the header for this same example
thnx
This Solution works Great!