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: 
karthickv
Partner - Creator
Partner - Creator

Macro to save the QVW file with User Name

Hi All,

Can you please share a macro which can help me to perform a reload & save the file with User Name ?

Lets say I have a Sales.qvw file, upon clicking the button, macro should run and the file should be reloaded & saved as Sales K1234.qvw. Where K1234 is the OSUser Name or QVUser Name.

Thanks,

Karthick V.

1 Solution

Accepted Solutions
zhadrakas
Specialist II
Specialist II

hi,

create the variable "vUser" with Definition =subfield(OSUser(),'\',2)

Then use this macro

sub Reload_Save
set docprop = ActiveDocument.GetProperties
Filename = docprop.FileName

set v = ActiveDocument.Variables("vUser")
Username = v.GetContent.String

ActiveDocument.Reload
ActiveDocument.SaveAs left(FileName, len(FileName)-4) & " " & Username & ".qvw"
end Sub

View solution in original post

5 Replies
zhadrakas
Specialist II
Specialist II

hi,

create the variable "vUser" with Definition =subfield(OSUser(),'\',2)

Then use this macro

sub Reload_Save
set docprop = ActiveDocument.GetProperties
Filename = docprop.FileName

set v = ActiveDocument.Variables("vUser")
Username = v.GetContent.String

ActiveDocument.Reload
ActiveDocument.SaveAs left(FileName, len(FileName)-4) & " " & Username & ".qvw"
end Sub

tamilarasu
Champion
Champion

Tim,

Just thought of sharing this line without creating a variable.

sub Reload_Save

set docprop = ActiveDocument.GetProperties

Filename = docprop.FileName

Username = ActiveDocument.Evaluate("subfield(OSUser(),'\',2)")

ActiveDocument.Reload

ActiveDocument.SaveAs left(FileName, len(FileName)-4) & " " & Username & ".qvw"

end Sub

karthickv
Partner - Creator
Partner - Creator
Author

Many thanks for your Response Tim. It worked.

karthickv
Partner - Creator
Partner - Creator
Author

Thank you so much for your response.

Nanri Tamil.

tamilarasu
Champion
Champion

No problem bro. Have a good day!!