Renaming a Word document from text in controls

P

Peter Stone

Access 2003/XP Pro

I'm opening a Word document, typing some text, and trying to rename it using
text from a combo and a text box on my form. The first two steps work OK, but
when I try to rename the document, it comes up with a message box "Object
required ".

Dim oWord As Object
Dim oDoc As Object

'Create the Word application object.
Set oWord = CreateObject("Word.Application")

'Open the sample document.
Set oDoc = oWord.Documents.Add("C:\t2hDoc\DocBlank.doc")

'Add text
oWord.Selection.TypeText "Start here."

'Save the new document
oWord.ActiveDocument.SaveAs Filename:="t2h" &
Me.Parent!cboDestL.Column(1).Value & Me.Parent!txtHd.Value & ".doc"

oWord.Visible = True

Thanks in advance

Peter
 
D

Douglas J. Steele

Assuming that this is being run from a module of a form being used as a
subform, try replacing

Me.Parent!cboDestL.Column(1).Value

with

Me!Parent.Form!cboDestL.Column(1)
 

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