Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
dhasharadh
Creator III
Creator III

macros are not working as expected...?

Hi All, 

as per our requirement we have to use 2 macros, when we use individually its both are working fine. but combining together its not working as expected. 

Please look into attached. Thanks Much in advance. 

@marcus_sommer @jagan  @tresesco  can any one you please look into this. 

 

BR,

Dhasharadh.

Labels (2)
1 Solution

Accepted Solutions
marcus_sommer

The command-line with /r parameter ist the same like the qmc-execution but you could use /l as parameter. With it the entire desktop client will be loaded but didn't save + close after the reload and any macro-execution - this means you need to add a save + close + quit macro-statements at the end of your macro to keep the task automatically. To the proper syntax for it take a look within the APIGuide.qvw.

- Marcus

View solution in original post

8 Replies
marcus_sommer

My suggestion is to apply all selections within the export-macro and then calling it per OnReload trigger and maybe also applying it to a button.

Beside this such logig could only work directly within the desktop client and not by reloading the app per qmc.

- Marcus

dhasharadh
Creator III
Creator III
Author

@marcus_sommer thanks much marcus, but here on reload trigger is not working as expected seems like a bug i guess, i read it in one article regarding the same that postreload and postreduce data triggers are not working. 

here the challenge is we can not write the button press trigger in the same macro, as the same macro triggered with the button.

and added all other selections in the same macro and just tried using the postreload trigger but didnt worked.

so to trigger the macro we have to use a button and to trigger the button we need an other macro which is not working. 

Any way to run the macro without using this button option or onpostreload option...??

Much appreciate your time Marcus. Thank you

 

BR,

Dhasharadh

marcus_sommer

If the export-macro didn't worked because it wasn't triggered from the OnReload trigger why should another macro in-between be helpful to trigger further things - if a macro isn't triggered it won't help if you chained or nest the macros/actions in any way. Means here just to add further complexity but not on the cause else on the impact.

Whereby the above said mustn't be really true. How do you check if the macro was triggered and executed or not? Just to look if there are new export-files is not enough because there are various reasons why the export may fail.

Please elaborate how and where the application is from which user reloaded? In which scenarios does it work (partly) and in which not? If not, what happens - errors, unexpected results, nothing?

- Marcus  

dhasharadh
Creator III
Creator III
Author

Thanks Marcus, 

the application is in our dev environment, and it is not going to be scheduled in QMC, we are planning to trigger it on 5th of every month using windows task scheduler. 

 

we wrote attached macro and used a button to run that macro, whenever we click on that button macro is getting executed and files are generated in the required format, but this macro have to run on its own without any manual task. 

and we used on post reload option which is not working, that is that reason we wrote an other macro to trigger the button, but unfortunately that is also not working as expected.

if you observe the macro we wrote msg like completed ( whenever the macro runs it will pop up a msg like completed.

 

marcus_sommer

You should have mentioned a windows-task execution per batch earlier - that is not really the same like using the desktop client. I assume you use /r as parameter which worked like a qmc-execution which hasn't an UI and could therefore not execute any macros, see:

Just-reload-whitout-Publisher 

- Marcus

dhasharadh
Creator III
Creator III
Author

@marcus_sommer, sorry i actually over looked i used post reduce option by mistake, when i used on post reload its working perfectly fine and am able to generate the files as expected. 

But as macro based apps are not executed in QMC, we have to  use windows batch scheduler to schedule this app, when i use /r in between qv.exe file and app name its just reloading but macro is not running. 

what i have to use in batch file to execute the app fully including macros.

marcus_sommer

The command-line with /r parameter ist the same like the qmc-execution but you could use /l as parameter. With it the entire desktop client will be loaded but didn't save + close after the reload and any macro-execution - this means you need to add a save + close + quit macro-statements at the end of your macro to keep the task automatically. To the proper syntax for it take a look within the APIGuide.qvw.

- Marcus

dhasharadh
Creator III
Creator III
Author

Hi Marcus, every thing was fine until we got the small change in the macro, now there is a error. 

please guide us, 

What is wrong with the below macro,

we are trying to place the generated text files in the \\qlkvapps001.flip.onmicrosoft.com\WUR folder for which we added few lines line Dim FilePath and thats it.

am getting bad file name or number error and this line is getting highlighted. 

Set MyFile = fso.CreateTextFile(strFile) 

Full Macro :

Sub export
ActiveDocument.clearAll true
curMonth = Month( DateAdd("M",-1, Date))
if curMonth<10 then curMonthS="0" & CStr(curMonth) else curMonthS=CStr(curMonth)
IF curMonth=1 OR curMonth=3 OR curMonth=5 OR curMonth=7 OR curMonth=8 OR curMonth=10 OR curMonth=12 Then
noofdays=31
else noofdays=30
end if

Dim wellNames(2)
wellNames(0)="Eschenfelden US"
wellNames(1)="Bierwang US"

Dim FileNames(2)
FileNames(0)="Esch"
FileNames(1)="Biew"

Dim FilePath(1)
FilePath(1) = "\\qlkvapps001.flip.onmicrosoft.com\WUR"

Set fso = CreateObject("Scripting.FileSystemObject")

For i = 0 to 1
ActiveDocument.Fields("%KEY_REPORT").Select WCONHIST,WCONINJH
ActiveDocument.Fields("GASMONTH").Select Year(Date)&"-"&curMonthS
ActiveDocument.Fields("SP.LANGBEZ_SSO_SPEICHER").Select wellNames(i)

strFile = FilePath(i) & FileNames(i) & "_UGS_01_" & curMonthS & "_" & noofdays & "_" & curMonthS & "_" & Year(Date) & ".txt"

Set MyFile = fso.CreateTextFile(strFile)

set table = ActiveDocument.GetSheetObject( "TB02" )
for RowIter = 0 to table.GetRowCount-1
set cell = table.GetCell(RowIter,0)
MyFile.WriteLine(cell.Text)
next
MyFile.Close
Next
ActiveDocument.clearAll true
ActiveDocument.Save
ActiveDocument.GetApplication.Quit

End Sub