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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using a macro to write to csv file

Hi all,

I want to write a macro to write a string out to a csv file.

Ive been looking on the internet and can't find an example of the code needed that works in qlikview.

I can get the string formated correctly in the macro, and I can get it to pop up in a message box, but I can't figure out how to simply write this string out to an externally located csv file. I want to simply append the string onto the end of the csv file (i.e on the next line) each time I run the macro.

Thanks

Dan

3 Replies
SunilChauhan
Champion II
Champion II

call following code on button click

sub sendtocsv

set

obj1 = ActiveDocument.GetSheetObject("CH1926")

obj1.Export "D:\Qlik2Finance\Work\SUNIL\Debtor_Booksize_daily_export\BOOKSIZE.csv"

,","

end

sub

inplace of CH1926 of give ur chartID

inplace of "D:\Qlik2Finance\Work\SUNIL\Debtor_Booksize_daily_export\BOOKSIZE.csv" give ur path

Sunil Chauhan
Not applicable
Author

Thanks Sunil, but its variables I want to write out rather than a sheet object.

Ive found a solution now:

Const ForAppending = 8 'Setting to append to end of csv file

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(f_name,ForAppending,TristateFalse)
f.WriteLine VB_WRITESTRING
f.Close

Seems to work on desktop client, hoping it will work on accesspoint as well.

Not applicable
Author

Thanks Sunil, but its variables I want to write out rather than a sheet object.

Ive found a solution now:

Const ForAppending = 8 'Setting to append to end of csv file

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(f_name,ForAppending,TristateFalse)
f.WriteLine VB_WRITESTRING
f.Close

Seems to work on desktop client, hoping it will work on accesspoint as well.