From: Peter Stone on
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

From: Douglas J. Steele on
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)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Peter Stone" <PeterStone(a)discussions.microsoft.com> wrote in message
news:B34C8DE0-996E-498D-8E91-C2B3C2941F46(a)microsoft.com...
> 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
>


From: Peter Stone on
Thank you Doug

Peter
 | 
Pages: 1
Prev: Scrolling Message
Next: remove a filter