Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Export to text file with fixed length data

Hi

I have written a macro to export the straight table in a qvw to a flat file (.txt) file and was able to specify the delimiter i wish to.

The macro which i used is as follows:

sub Export

Dim docProp

set docProp = ActiveDocument.GetProperties

Dim tmpFile  'used to create relative filepaths

tmpFile = docProp.MyWorkingDirectory

tmpFile = tmpFile & "External Data Sources\OperationalReportsOutput\"

set obj = ActiveDocument.GetSheetObject("CH01")

obj.Export tmpFile & "Activity" & ".txt",";"

end sub

Now i have to change the output data to a fixed length datatype. It means for suppose, i have 3 fields

Name  Address              Phonenumber

Sam    Greenville,USA    2159627856

Vizard Charlotte, USA    2527255632

If i gave a fixed length of 20 to the fields:and i specify no delimiter,

the output should look like

Sam                 Greenville,USA      2139627856

Vizard               Charlotte,USA       2527255632

So every record in the text file should end at the same point.

Any ideas!

12 Replies
Anonymous
Not applicable
Author

Yes, It is working. Thank You

Anonymous
Not applicable
Author

But just as a question, can we do it in macro! i mean fixed length fields while exporting

Gysbert_Wassenaar

Yes. Macro's are just vbscript. Find a good vbscript site to find out how to manipulate strings and write them to a file.


talk is cheap, supply exceeds demand