Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello users,
I am trying to open a file using a macro and then executing it.
I am getting error when i try below script.
I have defined vUserName =subfield(OSUser(),'\',2) in variable settings.
set v = ActiveDocument.Variables("vUserName") vUserName = v.GetContent.String filepath="C:\Users\("&vUserName&")\Documents\Sample.qvw"
is there anything wrong in the above script? can you please correct it and share the correct code
Thanks
Hello Settu
Thanks, I will check your solution in a while.
What if there are spaces in my file path as shown below?
set v = ActiveDocument.Variables("vUserName") vUser = v.GetContent.String filepath="C:\Users\"&vUser&"\Documents\New Documents\Sample.qvw"
Can you please provide alternate to the above script where i can consider spaces in the file path defined above?
try
SUB test1() set v = ActiveDocument.Variables("vUserName") vUser = v.GetContent.String filepath="C:\Users\"&vUser&"\Documents\New Documents\Sample.qvw" 'msgbox filepath ' for tests: qvpath = "C:\Program Files\QlikView\qv.exe" filepath = "d:\Qlik\Dev\30_QvdGenerators\model_oos.qvw" ' use chr(34) Set shell = CreateObject("WScript.Shell") shell.Run chr(34) & qvpath & chr(34) & " " & chr(34) & filepath & chr(34) END SUB