
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Passing variable to vbs
Hi guys,
I have a piece of vbs that simply displays a message box.
I have a batch file that calls the vbs from a macro
Set obj = createobject("Wscript.Shell")
Word = "Hello World"
obj.Run "h:\test2.vbs"
Set obj = Nothing
Is there a way to pass the "Word" variable from Qlikview to the vbs file?
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try it with the attachments - whereby Source called the Target.
Source:
Set obj = createobject("Wscript.Shell")
Word = "Hello World"
obj.Run "D:\CallVbsBatchWithParameterTarget.vbs" & " " & Word
Set obj = Nothing
Target:
Set objArgs = WScript.Arguments
WScript.Echo WScript.Arguments.Count
For Each strArg in objArgs
WScript.Echo strArg
Next
- Marcus


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try it with:
Word = ActiveDocument.Variables("YourVariable").GetContent.String
- Marcus

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Im not sure that passes it to the VBS?


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are right - my example transfers a qlikview-variable to the macro but not to the vbs-batch. For this take a lokk here: batch file - How to call Run() with parameters - Stack Overflow.
- Marcus

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I found that one already and couldnt quite work it out which is why i came here hoping for a bit of help


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try it with the attachments - whereby Source called the Target.
Source:
Set obj = createobject("Wscript.Shell")
Word = "Hello World"
obj.Run "D:\CallVbsBatchWithParameterTarget.vbs" & " " & Word
Set obj = Nothing
Target:
Set objArgs = WScript.Arguments
WScript.Echo WScript.Arguments.Count
For Each strArg in objArgs
WScript.Echo strArg
Next
- Marcus

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Marcus,
Thank you for this post, I have one requirement from the my office,
The requirement is how to use Binary Load variables in VB Script.
Because in my Binary Load I was pass parameters to access .QVW file than I want to Reload that file and generate System tables and Load Script.
Bellow is the my Binary load Script and VB script,
so could you please help me to write VB Script for this.
Binary load:
BINARY [$(QVW_Dir)\$(Tab).qvw];
VB Script:
sub writeScriptToFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Word = ActiveDocument.Variables("Tab").GetContent.String
Set objFile = objFSO.OpenTextFile("D:\QLIKVIEW\Export file\Scriptfile.txt", 2,True)
objFile.Write(ActiveDocument.GetProperties.Script)
objFile.Close()
end sub
Sub ExportXML
set obj = ActiveDocument.GetSheetObject("CH01")
Word = ActiveDocument.Variables("Tab").GetContent.String
obj.ExportXML "D:\QLIKVIEW\Export file\Systemtables.xls"
End sub
The above is the my VB Script. But it is not working, when I was run .bat file for access .QVW(Binary Load) file into another .QVW file.
The above script it is load only current .QVW file Load Script and it is not load .QVW(Binary Load) file.
Could you please help for this scenario.
Thanks ,
Bakshu


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It's not quite clear for me. You are performing the (binary) reload of an application and after the reload the macros which creates the system-table and export them should be executed?
- Marcus

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Marcus,
Yes Marcus, It should be executed after reload the application, I want to fetch the Binary load Edit Script and System tables and store into another location.
Can you please help to this.
Thanks,
Bakshu.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I assume that your batch contained a command-line statement to reload the application with the parameter /r. I'm not sure but I believe it's the counter-part to the qmc-reloading feature performed through the qvb.exe. There none or at least lesser UI parts are included to perform the reload and therefore all actions which need a minimum of UI features are not executed respectively ignored.
But by using VBS for all parts of your task (opening, reload, export, whatever ...) you could bypass this restriction. Here some links which will be helpful to get this to work:
Re: Vbs - passing parameters to opendoc or opendocex
Re: tring to export a chart into jpg file
- Marcus
