Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Execute macro from script

Hello. I want to load data from 1C (Russian ERP). So, I use this macro:

sub v82query

Dim ServerName

Dim InfoBaseName

Dim InfoBasesAdminName

Dim InfoBasesAdminPass

ServerName = ""

InfoBaseName = "

InfoBasesAdminName = "

InfoBasesAdminPass = ""

set conn = CreateObject("V83.COMConnector.1")

Set v82 = conn.Connect("Srvr=""" + ServerName + """;Ref=""" + InfoBaseName + """;Usr=""" + InfoBasesAdminName + """;Pwd=""" + InfoBasesAdminPass + """;")

query_1c = "ВЫБРАТЬ" &_

" Представление(цТребованиеНакладнаяДляСХМатериалы.Поле) Как  Pole"& vbNewLine & _

"ИЗ"& vbNewLine & _

" Документ.цТребованиеНакладнаяДляСХ.Материалы КАК цТребованиеНакладнаяДляСХМатериалы " & vbNewLine & _

set v8query = v82.NewObject("Query")

v8query.text = query_1c

set result = v8query.Execute

set m = result.Choose

do while m.next

set sql_string = ActiveDocument.DynamicUpdateCommand("INSERT INTO * "& vbNewLine & _

"(Pole) " & vbNewLine & _

"VALUES (" & m.Pole &")")

loop

ActiveDocument.GetApplication.Refresh

end sub

And I use a simple script:

Table1:

LOAD * INLINE [

    Pole

];

left join

Table2:

LOAD  C as Pole

FROM

And I want to call my macro from script, because I try to dynamic update Table1 and left join Table2.

Please, help me, how to call my macro from my script before left join?

3 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Unfortunately, that will not work. You cannot call macro subs from the load script. You can use macro functions in a load statement (with some limitations), but I don't think that will help in this case.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jonathandienst
Partner - Champion III
Partner - Champion III

It may be possible to put your macro into a .vbs statementfile, and execute the macro using cscript.exe in a batch file. You will need to drop the ActiveDocument.GetApplication.Refresh statement and reload the document from the same batch file using the qv.exe /R option.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

OK, thank you. I think that I need  try another way. I want to load data from ERP to one qlik app, and in the another app open it and join tables from Excel.