Using an ASK Variable in Macro

S

Steve

Hi,

I have a template I have been working on for some time now. I have
run into a snag. I am using a combo box with a macro attached that
will insert the appopriate file from a specified drive and path when
chosen from the drop down. This uses the INCLUDETEXT field.

This template and subdocuments will be located in different drives and
folders on each users computer.

To change to INCLUDETEXT field to the correct path I have inserted an
ASK field to run when the document opens, it then takes this result
(variable) and inserts it in the INCLUDETEXT fields which I have
modified. This works great with the one problem.

The macro that I am using for the drop down box inserts the file with
a drive and folder path. I have tried to use the same ASK result
(variable) to put in place of the path but it doesn't like this.

Is there any way I can use the result of an ASK in a macro? Or is
there some other way. Some other field that will work in both the
document and a macro.

What I have now works fine and updates all my includetext fields no
problem. I just can't get the macro to use some type of variable that
the user types in when the document opens.

Regards
Steve
 
D

Doug Robbins

If you want to obtain information from the user for use with a macro, you
should use an InputBox. In this case however, it is probably more
appropriate to use the Dialogs.wdDialogInsertFile.Show command as that will
display the insert file dialog and allow the user select the file to be
inserted.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
C

Cindy M -WordMVP-

Hi Steve,

Difficult to determine exactly what problem you're running into, since
you don't specify in what WAY your solution isn't working. My first
thought would be that the user isn't typing double-backslashes for the
file path you're substituting into IncludeText? Or that you have a
version of Word that requires single, rather than double-backslashes
when the path comes through a field?

FWIW, when I need something like I understand you're doing, I'll keep
the file path in a document PROPERTY (File/Properties/Custom) and change
the property, using a DocProperty field in the InsertText field.
I have a template I have been working on for some time now. I have
run into a snag. I am using a combo box with a macro attached that
will insert the appopriate file from a specified drive and path when
chosen from the drop down. This uses the INCLUDETEXT field.

This template and subdocuments will be located in different drives and
folders on each users computer.

To change to INCLUDETEXT field to the correct path I have inserted an
ASK field to run when the document opens, it then takes this result
(variable) and inserts it in the INCLUDETEXT fields which I have
modified. This works great with the one problem.

The macro that I am using for the drop down box inserts the file with
a drive and folder path. I have tried to use the same ASK result
(variable) to put in place of the path but it doesn't like this.

Is there any way I can use the result of an ASK in a macro? Or is
there some other way. Some other field that will work in both the
document and a macro.

What I have now works fine and updates all my includetext fields no
problem. I just can't get the macro to use some type of variable that
the user types in when the document opens.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 

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