Passing report string path to code

J

Joan

Hi,

I have created several reports as either a Word document or a Word template
and I have written code on events in Access to open up these reports to
print them The code works fine however I would like for the user or
administrator to be able to pass a different path name to the code if the
location of these documents or templates change. When I try putting the
variable with the string path in my code I either get a sytax error or
Microsoft Word opens but not document is active. Could someone help me
figure out what I'm doing wrong?

I've created a form with textboxes for the user to enter new path names and
the path names are stored in public string variables. All these documents
and templates are stored in a folder called Templates. To make it easier
for the user, I am leaving the "...Templates\Booking Confirmation2.doc" part
of the path name in my code so that the user just needs to enter the Drive
letter and any other folders that the Templates folder could be located in.
For instance if the Templates is just located on the C drive the user would
enter C:\ Say that the public variable BookCBlank holds that string
C:\.
Below is the part of my code that is relevant:

WordObj.Documents.Add _
Template:=" '" & BookCBlank & "' Templates\BOOKING CONFIRMATION2.doc",
NewTemplate:=False
DoEvents
WordObj.Activate

When I run my form with the code like above, Microsoft Word opens but no
document is active.

Could someone help me with the correct syntax when adding this variable to
my path string?

Thanks,
Joan
 

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