Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2005

Tip: Looking for answers? Try searching our database.

Setting the file path

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Roger - 31 Mar 2005 18:03 GMT
I'm trying to set a file path for the purpose of saving a Word Doc to the
correct folder location.  The entire path, except for the specific subfolder
is constant.  For example:

\\lv-abc\defaultpath\CaseDocs\variable

In the document that is being saved, "variable" is a bookmarked string of
text named CaseNumber.

So far I have:
ActiveDocument.Variables("CaseNumber").Value = CaseNumber
   Options.DefaultFilePath(wdDocumentPath) =
"\\lv-abc\defaultpath\CaseDocs\"

This sets my path to the CaseDocs folder, but I can't figure out how to get
the variable "CaseNumber" into the path statement.

Word 2003:  and I apologize if this isn't being sent as plain text.  I set
my account options to send as plain text, but my compose window is not
showing in plain text, so I'm not sure how it's going out.

Thanks
Jay Freedman - 31 Mar 2005 21:42 GMT
Hi Roger,

I think there's a bit of confusion here, caused by multiple meanings for the
word "variable".

In VBA, you can have variables that are just memory locations defined within
the macro. Each one should be declared in a Dim statement and given a
specific data type, for example

  Dim CaseNumber As String

The expression ActiveDocument.Variables("CaseNumber") refers to something
else, a "document variable" that is stored in the document file. I don't
think that belongs in this macro at all.

Finally, you need to fill the variable CaseNumber by retreiving the contents
of the bookmark by that name. I think this is what you want (the
space-and-underscore is a continuation marker, meaning "this line and the
next one are part of the same statement"):

  Dim CaseNumber As String
  CaseNumber = _
     ActiveDocument.Bookmarks("CaseNumber").Range.Text
  Options.DefaultFilePath(wdDocumentPath) = _
     "\\lv-abc\defaultpath\CaseDocs\" & CaseNumber

An alternative to this method is shown at
http://word.mvps.org/FAQs/MacrosVBA/ChangeSaveAsPath.htm.

Signature

Regards,
Jay Freedman
Microsoft Word MVP          FAQ: http://word.mvps.org

> I'm trying to set a file path for the purpose of saving a Word Doc to
> the correct folder location.  The entire path, except for the
[quoted text clipped - 18 lines]
>
> Thanks
Roger - 31 Mar 2005 23:52 GMT
Thanks Jay!  I used the with dialogs code and it worked great.
Roger

> Hi Roger,
>
[quoted text clipped - 47 lines]
> >
> > Thanks

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.