Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Writing log using a VB macro

Hi

I'm trying to use a VB macro inside the QV loading script in order to write an activity log, but I'm not having luck.

First, this is the code included in the macro section:

Dim objFSO

Dim logFile

Function openOutputFile(filename)

Rem *** Create and open an output file

    CONST ForWriting = 2

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Set openOutputFile = objFSO.OpenTextFile(filename, ForWriting, True)

End Function

CONST LOGFILE_NAME = "D:\tmp\test1.log"

Function WriteLog(message)

    logFile = openOutputFile(LOGFILE_NAME)

    logFile.WriteLine(message)

    logFile.Close

End Function

and inside the QV script, (i.e. in Main tab) the WriteLog function is invoked:

LET x = WriteLog("test");

The file is being created, but it is empty.

Could you please provide some advice

Thanks in advance!

Regards,

Jesús

1 Solution

Accepted Solutions

Re: Writing log using a VB macro

Hi Jesús,

Just change this line

logFile = openOutputFile(LOGFILE_NAME)

to this line

Set logFile = openOutputFile(LOGFILE_NAME)

That should work.

Miguel

1 Reply

Re: Writing log using a VB macro

Hi Jesús,

Just change this line

logFile = openOutputFile(LOGFILE_NAME)

to this line

Set logFile = openOutputFile(LOGFILE_NAME)

That should work.

Miguel

Community Browser