Execute Literal VBA-code on a variable or as text string.

M

Marcel

Hi,

Is there a command in VBA that executes literal vba code supplied on a variable or as text string?

I'm recieving a textstring from a word document like ' Options.DefaultFilePath(Path:=wdUserTemplatesPath) = "" ' and want to execute this as it was code in a macro.

I know this from another language where I can write eval("varA + varB") becomes 3.

Regards,

Marcel
 
M

Marcel

Marcel said:
Hi,

Is there a command in VBA that executes literal vba code supplied on a variable or as text string?
I'm recieving a textstring from a word document like '
Options.DefaultFilePath(Path:=wdUserTemplatesPath) = "" ' and want to
execute this as it was code in a macro.
I know this from another language where I can write eval("varA + varB") becomes 3.

Regards,

Marcel

Hi, I maybe know how I can realize this.

1. Create a 'universal' macro by code.
2. Put the string literal in it as the instruction to be executed.
3. run the created macro with application.run "macro_name"

Marcel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top