Saving linked word doc with specific name

  • Thread starter Morgan Gartland via AccessMonster.com
  • Start date
M

Morgan Gartland via AccessMonster.com

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
 
J

John Nurick

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
 
M

Morgan Gartland via AccessMonster.com

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

John said:
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
 
J

John Nurick

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






Morgan Gartland via AccessMonster.com said:
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

John said:
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
 

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