Skip to main content

Accessing the file system using VBScript


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.


This routine logs selection to a text file


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


Join the Analytics Modernization Program

Modernize by leveraging your QlikView investment to begin using Qlik Sense on the Cloud.

Want to know more?
Remove banner from view