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

Macro to append script

Hello QV Experts,

Below macro in (first.qvw) will read a text file and writes it to another (recon.qvw) file. The text file contains SQL select statements. I am facing a issue with below code.

1. When I run the macro it just opens the recon.qvw file, but the script is not getting added. Please help.

Thanks in advance

sub UpdateScriptFromfile

set FSO= createobject("Scripting.FilesystemObject")
set openReconFile=FSO.OpenTextFile("C:\Qlikview\buildsql.txt")
scriptBackup=openReconFile.ReadAll
openReconFile.Close
msgbox(scriptBackup)
set newdoc = GetObject("C:\Qlikview\recon.qvw")
newdoc.GetProperties.Script = scriptBackup

end sub

1 Solution

Accepted Solutions
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

    Try this.

   

sub UpdateScriptFromfile


set FSO= createobject("Scripting.FilesystemObject")
set openReconFile=FSO.OpenTextFile("C:\Qlikview\buildsql.txt")
scriptBackup=openReconFile.ReadAll
openReconFile.Close
msgbox(scriptBackup)
set newdoc = GetObject("C:\Qlikview\recon.qvw")
set abc = newdoc.GetProperties
abc.Script = scriptBackup
newdoc.setproperties abc


end sub

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!

View solution in original post

2 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

    Try this.

   

sub UpdateScriptFromfile


set FSO= createobject("Scripting.FilesystemObject")
set openReconFile=FSO.OpenTextFile("C:\Qlikview\buildsql.txt")
scriptBackup=openReconFile.ReadAll
openReconFile.Close
msgbox(scriptBackup)
set newdoc = GetObject("C:\Qlikview\recon.qvw")
set abc = newdoc.GetProperties
abc.Script = scriptBackup
newdoc.setproperties abc


end sub

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Thank you so much Kaushik

It worked with your change.