Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Importing / Linking / August 2005

Tip: Looking for answers? Try searching our database.

Saving linked word doc with specific name

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Morgan Gartland - 17 Aug 2005 14:27 GMT
I have some code that allows me to open a new word document from a template i
have created (see below). i would like to be able to force the document to
have a specific name and location when the user has finished and wants to
save the document.

Const conTEMPLATE_NAME = "Statement.dot "

  Set mobjWordApp = New Word.Application
  With mobjWordApp
     .Visible = True
     .WindowState = wdWindowStateMaximize
     .Documents.Add Template:=("S:\Statement .dot")
  End With
End Sub

I am using Access 2000 and Word 2003. any help and a detailed explanation (
fairly new to ACCESS VB etc) would be most appreciated.
Morgan
John Nurick - 17 Aug 2005 15:28 GMT
Hi Morgan,

It's really hard to lock Word down that tightly. Instead, save the new
document where you want it before you let the user at it.

   Dim mobDoc As Word.Document
   ...
   With mobWordApp
       Set mobDoc = .Documents.Add blah blah
       mobDoc.SaveAs "C:\foo\bar.doc"
       .Visible = True
       .WindowState = wdWindowStateMaximize
   End With

>I have some code that allows me to open a new word document from a template
>i
[quoted text clipped - 16 lines]
> fairly new to ACCESS VB etc) would be most appreciated.
> Morgan
Morgan Gartland - 22 Aug 2005 15:07 GMT
Hi John

Thanks for your advice. I have just given this a go and it doesn't like the
following line have tried a few other options and still no joy.

Dim mobDoc As Word.Document

could you possibly point me in the right direction again.
Thanks
Morgan

>Hi Morgan,
>
[quoted text clipped - 15 lines]
>> fairly new to ACCESS VB etc) would be most appreciated.
>> Morgan
John Nurick - 22 Aug 2005 15:52 GMT
Hi Morgan,

If it accepts
   Set mobjWordApp = New Word.Application
it's very strange that it doesn't accept
   Dim mobDoc As Word.Document

Go to Tools|References (in the VB editor) and make sure that "Microsoft Word
X.X Object Model" is checked. (The X.X varies with your version of Office.)
Also, make sure that you have
   Option Explicit
as the first line of the code module.

I'd probably use something like this:

   Dim mobWordApp As Word.Application
   Dim mobDoc As Word.Document

   Set mobWordApp = New Word.Application
   With mobWordApp
       Set mobDoc = .Documents.Add Template:="S:\Statement .dot"
       mobDoc.SaveAs "C:\foo\bar.doc"
       .Visible = True
       .WindowState = wdWindowStateMaximize
   End With

> Hi John
>
[quoted text clipped - 28 lines]
>>> fairly new to ACCESS VB etc) would be most appreciated.
>>> Morgan
 
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.