Renaming a linked Word document from Access

  • Thread starter Thread starter Peter Stone
  • Start date Start date
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
 
Have you tried:

Name "CurrentFileName.doc" As cboDest.Column(1) & me.txtHeading.value & ".doc"
 
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"
 
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
 
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
 
Back
Top