Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
pavandbs
Contributor III
Contributor III

Read variable into macro code with out active document

Hello,

I have set of .xls files want to convert to csv because of some issue in loading. I have a script to read file by file then call macro code with in that loop. Problem is I am passing file into variable and passing that variable value into macro. Understand active document wont work with in macro, is there any alternate for this ? Below is my macro code:

strValueToDisplay = ActiveDocument.Variables("vFile").GetContent().String 


vFile have file path and name. On edit module --> its working fine. However calling macro from script is not working. Please advice.


Thanks,

Pavan

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Pass your variable value as a string to the Function. ie in the script:

LET vExecFunction = RepairXLS('$(vFile)');

and in the module:

function RepairXLS(myfile)

-Rob

http://masterssummit.com

http://qlikviewcookbook.com

View solution in original post

4 Replies
Anil_Babu_Samineni

May be this? I've remove the () from extension of GetContent..

strValueToDisplay =  ActiveDocument.Variables("vFile").GetContent.String

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
pavandbs
Contributor III
Contributor III
Author

Hi Anil,

It did not work. Understand with in community that, if we call macro with in script with ActiveDocument it wont work.

Attached document for your reference. The objective of the document is

1. Read .XLS file

2. Assign the filename with path to a variable

3. call macro function to convert the XLS to cls.

Edit module --> Test is working fine. But when I call the same macro from script is not working. I guess its because of ActiveDocument.

Thanks,

Pavan

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Pass your variable value as a string to the Function. ie in the script:

LET vExecFunction = RepairXLS('$(vFile)');

and in the module:

function RepairXLS(myfile)

-Rob

http://masterssummit.com

http://qlikviewcookbook.com

pavandbs
Contributor III
Contributor III
Author

Thanks Rob it worked.

Regards,

Pavan Ch