Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
leenlart
Creator
Creator

Create a filename for ServerSideExportEx based on variable

Hello,

This seems like it should be SOOO SIMPLE but I'm pulling my hair out :

I have table that the user will choose to save using a button. 

In my vbscript for the button, I am trying to modify the path and name where the ServerSideExportEx saves the file. 

This works:

tb.ServerSideExportEx "D:\QlikView_documents\Developpement\1-Sources\XML\Provisions.xml" , ";" , 3 '0=HTML, 1=Text, 2=Bitmap, 3=XML, 4=QVD, 5=BIFF

But I'd like to pass the path and the file name as variables. 

The file name will be "Provisions_" & [year - month selected]. 

My file path and the year-month selected are both variables in the qwd, so I tried this :

set dateProvisions = ActiveDocument.Variables("vDateProvision")

set pathProvisions = ActiveDocument.Variables("vRepSourcesXml")

set fileName = "Provisions_$(vDateProvision).xml"

This bombs. 

My next work-around was to create a variable in the qwd that saves the file name as "Provisions_"&$(vDateProvision)&".xml"


I can't get my variable to work correctly either! 

In the variables menu, I set the variable to "Provisions_"&$(vDateProvision)&".xml" -- no good. 

Then I tried concat("Provisions_",$(vDateProvision),".xml") -- also no good. 


Does anyone have any suggestions ?


Thanks!

14 Replies
jerrysvensson
Partner - Specialist II
Partner - Specialist II

Does the QlikView server account have write access to the path?

leenlart
Creator
Creator
Author

The msgbox doesn't run. 

So do you think that my dateProvisions is not a string - could that be the problem?

The server does have write access, cause if I leave it as :

tb.ServerSideExportEx "D:\QlikView_documents\Developpement\1-Sources\XML\Provisions_201809.xml" , ";" , 3

It works fine. 

jerrysvensson
Partner - Specialist II
Partner - Specialist II

Strange

I would try:

MsgBox pathProvisions.GetContent.String

MsgBox dateProvisions.GetContent.String

Just to make sure everything is ok.

And then start adding them together one after the other. Using MsgBox

leenlart
Creator
Creator
Author

Ok, so your method helped.  Thanks!

Here is the final thing that works correctly :

Sub Save_Provisions

dim dateProvisions, fileName

set tb = ActiveDocument.GetSheetObject("TB24")

set dateProvisions = ActiveDocument.Variables("vDateProvision")

set pathProvisions = ActiveDocument.Variables("vRepSourcesXml")

tb.ServerSideExportEx pathProvisions.GetContent.String  & "\" & "Provisions_" & dateProvisions.GetContent.String & ".xml", ";" , 3

end sub


I was missing a .GetContent.String after pathProvisions. 

Thanks so much for your help. 

petter
Partner - Champion III
Partner - Champion III

As Jerry pointed out if dateProvisions really is a variable object then dateProvisions.GetContent.String should work. But if dateProvisions is not a variable object or nil then it will fail.