Skip to main content Skip to complementary content

Accessing the file system using VBScript

When using the internal VBScript interpreter, it is possible to get hold of a reference to the local file system by using a statement like the following:

set fso = CreateObject("Scripting.FileSystemObject")

This reference can then be used for operations towards the file system.

Example

This routine logs selection to a text file

Example:  

sub LogFunction rem ** This routine logs selection to a text file ** set fso = CreateObject("Scripting.FileSystemObject") set mypath = ActiveDocument.GetProperties directory = mypath.MyWorkingDirectory On Error Resume Next rem ** See if file already exists. ** set filFile = fso.GetFile(directory & "log.txt") rem ** If not, then create it. ** if Err <> 0 then set filFile = fso.CreateTextFile(directory & "log.txt") end if set txsStream = filFile.OpenAsTextStream(8) 'For Appending set doc = ActiveDocument set mySelections = doc.fields("Field").GetSelectedValues for i = 0 to mySelections.Count - 1 txsStream.WriteLine Now & " " & mySelections.Item(i).text next txsStream.WriteBlankLines 1 txsStream.Close end sub

 

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!

Join the Analytics Modernization Program

Remove banner from view

Modernize without compromising your valuable QlikView apps with the Analytics Modernization Program. Click here for more information or reach out: ampquestions@qlik.com