Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

OnOpen Macro not running through QEMC

Hi all

I hope someone can help me.

I have a qlikview document with an onopen macro.  This macro simply moves some files from one location to another and then closes the document.  This works fine when I manually open the document.  When I schedule it to run (or click on run) from the Qlikview Enterprise Management Console, the macro doesn't seem to run.

Can anyone suggest why this may be and what I can do to correct it?

This is the part of the macro that moves the files:

Sub Movefiles()

Dim OldPath, OldPath1, NewPath, Fileprefix, Fileprefix1, FileSysObj

On Error Resume Next

OldPath = "Z:\QlikView_SourceDocs_V10\Additional Data Sources\Text"

OldPath1 = "Z:\QlikView_SourceDocs_V10\Additional Data Sources\Text"

NewPath = "Z:\QlikView_SourceDocs_V10\Additional Data Sources\Text\HIST"

Fileprefix = "TDH_AR_HIST_*"

Fileprefix1 = "TDH_TM_201*"

If Right(OldPath, 1) <> "\" Then

OldPath = OldPath & "\" & Fileprefix

End If

If Right(OldPath1, 1) <> "\" Then

OldPath1 = OldPath1 & "\" & Fileprefix1

End If

Set FileSysObj = CreateObject("Scripting.FileSystemObject")

FileSysObj.MoveFile OldPath, Newpath

FileSysObj.MoveFile OldPath1, Newpath

End Sub

Many thanks.

Justine

1 Solution

Accepted Solutions
arieidel
Contributor II

Re: OnOpen Macro not running through QEMC

From de QV Load Script you can type an EXECUTE sentence to execute a DOS command through a .cmd or a .bat files.

5 Replies
Employee
Employee

Re: OnOpen Macro not running through QEMC

Hey Justine,

When QEMC/Publisher executes a macro it does so as the user that is running the Publisher service.

Make sure that the user has access to the folder where you are accessing files and also that the Z: drive is a valid path for that user. Most likely if you have never logged on with that user the mapping won't exists so you might want to go with the full folder name instead.

When you are reloading the document locally you are executing the macro as your user.

Also make sure that the macro has full system access and that the server is allowed to execute macros.

Not applicable

Re: OnOpen Macro not running through QEMC

Thanks for the speedy response Alexander.

I shall check what you have suggested and post back here tomorrow.

Justine

jerrysvensson
Valued Contributor II

Re: OnOpen Macro not running through QEMC

OnOpen macro will not trigger in Publisher.

If you want your files to be copied during loading it is better to call the macro from the script.

Alexander has a point also. Never use mapped drive, use UNC path instead.

arieidel
Contributor II

Re: OnOpen Macro not running through QEMC

From de QV Load Script you can type an EXECUTE sentence to execute a DOS command through a .cmd or a .bat files.

Not applicable

Re: OnOpen Macro not running through QEMC

Thanks for all helpful answers.

Community Browser