Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Creator
Creator

OSUser in Macro file path

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

 

Labels (2)
1 Solution

Accepted Solutions
Highlighted

Can you try this.?

set v = ActiveDocument.Variables("vUserName")
vUser = v.GetContent.String
filepath="C:\Users\"&vUser&"\Documents\Sample.qvw"

View solution in original post

3 Replies
Highlighted

Can you try this.?

set v = ActiveDocument.Variables("vUserName")
vUser = v.GetContent.String
filepath="C:\Users\"&vUser&"\Documents\Sample.qvw"

View solution in original post

Highlighted
Creator
Creator

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?

Highlighted
Contributor III
Contributor III

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