Renaming a linked Word document from Access

P

Peter Stone

Access 2003/XP Pro
I want to create and link MS Word Documents from Access.
I have put an unbound frame on an Access form that on double-clicking opens
a blank document in Word. The SourceDoc property is C:\Doc\Doc1.doc.

I would like to rename the document using text from the controls on my form.
E.g. if cboDest.Column(1) is North Beach and txtHeading is Calzone's
Restaurant, I would like to Save As: North Beach Calzone's Restaurant.

Thank you
 
M

mjmcevoy

Have you tried:

Name "CurrentFileName.doc" As cboDest.Column(1) & me.txtHeading.value & ".doc"
 
M

mjmcevoy

Will most likely need to add the me. and .value to the combo baox name as well.
 
P

Peter Stone

Thanks for the suggestions.
I used the following:
Name "Doc1.doc" As Me.Parent!cboDest.Column(1).Value &
Me.Parent!txtHeading.Value & ".doc"

I get a message "Object required"
 
P

Peter Stone

Here is my current attempt-which results in the message: Object required

'Private Sub cmdOpenWord_Click()
On Error GoTo Err_cmdOpenWord_Click

Dim LWordDoc As String
Dim oApp As Object

'Path to the word document
LWordDoc = "c:\Doc\DocBlank.doc"

If Dir(LWordDoc) = "" Then
MsgBox "Document not found."

Else
'Create an instance of MS Word
Set oApp = CreateObject(Class:="Word.Application")
oApp.Visible = True

'Open the Document
oApp.Documents.Open filename:=LWordDoc
Name "DocBlank.doc" As Me.cboDest.Column(1).Value &
Me.txtHeading.Value & ".doc"
End If

Exit_cmdOpenWord_Click:
Exit Sub

Err_cmdOpenWord_Click:
MsgBox Err.Description
Resume Exit_cmdOpenWord_Click

End Sub

Peter
 
P

Peter Stone

Your first answer was correct

oWord.ActiveDocument.SaveAs Filename:="t2h" _
& Me!cboDestL.Column(1) & Me!txtHd.Value & ".doc"

The combo doesn't require the .Value

Thank you

Peter
 

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