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

facing error in macro code for creating new QVW File

Hi

In my file i am writing macro code for creating a new QVW File from existing QVW File. And i am giving the New QVW File Name as current date and time.

Pls check the below code, which is in BOLD line there i am facing error.

sub CreateNewQVW

Set vNP=ActiveDocument.Variables("vNewPath")

set lb=ActiveDocument.GetApplication.CreateDoc

set vp= "Test"&replace(Date(),"-","")&"_"&replace(Time(),":","") // Here i am getting an error i.e; Object required: '[string: "Test22072011_072816 "]'

lb.SaveAs vNP.GetContent.String &"\"& vp.GetContent.String&".qvw"

end sub

Can anyone help on this issue.

Thanks in advance

1 Solution

Accepted Solutions
danielrozental
Master II
Master II

following line is also wrong, it should be something like

lb.SaveAs vNP.GetContent.String &"\"& vp &".qvw"

View solution in original post

4 Replies
danielrozental
Master II
Master II

you don't need to use "set" there, set is only for objects not for variables.

vp= "Test"&replace(Date(),"-","")&"_"&replace(Time(),":","")

danielrozental
Master II
Master II

following line is also wrong, it should be something like

lb.SaveAs vNP.GetContent.String &"\"& vp &".qvw"

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

Remove the "set" on the error line. Set is for objects, which is what are creating in the first two lines. The third line is a string, which is not an object.

Hope that helps

Jonathan

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

Hi Daniel,

You make me free now , i am facing this problem from last two hours.

I had one more doubt , i.e; can we pass the QVS file for new QVW file from Existed QVW file using macro.

i.e; When i am creating new file itself then  it should pass the script QVS file.

How i can update in below code.

Sub Test123

Set vNP=ActiveDocument.Variables("vNewPath")

    set lb=ActiveDocument.GetApplication.CreateDoc

    vp= "Test"&replace(Date(),"-","")&"_"&replace(Time(),":","")

    lb.SaveAs vNP.GetContent.String &"\"& vp &".qvw"

End Sub

Thanks in Advance