I am collecting info from an MSAccess record and trying to merge it in Word.
I would like this to work with any version of Word that the user may have
installed. My MSAccess app will be a runtime app that I will be putting on
various machines in different workplaces.
Here is the code I am running from MSAccess:

Public Function AddressBlock() As Boolean

Dim wd As Object
Dim wdActiveDoc As Object 'RM: Added this to help ensure that you're
'working on the document you intend to.
Dim wdField As Object 'RM: Note the change in name here to avoid
'ambiguity with the Field object in both Word and
'Access. As well, I changed the type, since
'(like Word.Application), you have to use late
'binding.

Set wd = CreateObject("Word.Application")
wd.Visible = True

wd.Application.ScreenUpdating = False

Set wdActiveDoc = wd.Documents.Open("K:\legalper\merge_ad.doc ", False,
False, _
False, "", "", False, "", "", 0)

With wdActiveDoc.MailMerge
.Destination = 0
.Execute
End With
wd.Windows("merge_ad.doc ").Activate
wd.ActiveWindow.Close 0
'It bombs here with "Automation error: The object invoked has disconnected
from its clients", and the next line is highlighted.
'What I'm trying to do here is open merge_ad.doc, merge it, close
merge_ad.doc, then save the
'resulting merged doc as "merged_ad.doc"
wdActiveDoc.saveas Filename:="K:\legalper\merged_ad.doc", FileFormat:=0

Thanks in advance,
Kathy

Re: Starting MSWord Merge from MSAccess by Doug

Doug
Thu Nov 29 11:22:02 PST 2007

In place of

wd.Windows("merge_ad.doc ").Activate
wd.ActiveWindow.Close 0

use

wdActiveDoc.Close wdDoNotSaveChanges

Note, you do not show that you have declared wdActiveDoc as a document
object.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Kathy Webster" <slickdock@yahoo.com> wrote in message
news:474f0729$0$2338$4c368faf@roadrunner.com...
>I am collecting info from an MSAccess record and trying to merge it in
>Word. I would like this to work with any version of Word that the user may
>have installed. My MSAccess app will be a runtime app that I will be
>putting on various machines in different workplaces.
> Here is the code I am running from MSAccess:
>
> Public Function AddressBlock() As Boolean
>
> Dim wd As Object
> Dim wdActiveDoc As Object 'RM: Added this to help ensure that you're
> 'working on the document you intend to.
> Dim wdField As Object 'RM: Note the change in name here to avoid
> 'ambiguity with the Field object in both Word and
> 'Access. As well, I changed the type, since
> '(like Word.Application), you have to use late
> 'binding.
>
> Set wd = CreateObject("Word.Application")
> wd.Visible = True
>
> wd.Application.ScreenUpdating = False
>
> Set wdActiveDoc = wd.Documents.Open("K:\legalper\merge_ad.doc ", False,
> False, _
> False, "", "", False, "", "", 0)
>
> With wdActiveDoc.MailMerge
> .Destination = 0
> .Execute
> End With
> wd.Windows("merge_ad.doc ").Activate
> wd.ActiveWindow.Close 0
> 'It bombs here with "Automation error: The object invoked has disconnected
> from its clients", and the next line is highlighted.
> 'What I'm trying to do here is open merge_ad.doc, merge it, close
> merge_ad.doc, then save the
> 'resulting merged doc as "merged_ad.doc"
> wdActiveDoc.saveas Filename:="K:\legalper\merged_ad.doc",
> FileFormat:=0
>
> Thanks in advance,
> Kathy
>



Re: Starting MSWord Merge from MSAccess by Kathy

Kathy
Thu Nov 29 12:37:54 PST 2007

I think I wasn't clear. It is successful up to and including :

> wd.Windows("merge_ad.doc ").Activate
> wd.ActiveWindow.Close 0

It bombs when executing this next line:

wdActiveDoc.saveas Filename:="K:\legalper\merged_ad.doc",
FileFormat:=0

...with the message "The object invoked has disconnected from its clients."
I don't know how to reactivate the screen that shows the RESULTS of the
merge to new document, and save THAT as "merged_ad.doc"



"Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
news:eGhrj0rMIHA.484@TK2MSFTNGP06.phx.gbl...
> In place of
>
> wd.Windows("merge_ad.doc ").Activate
> wd.ActiveWindow.Close 0
>
> use
>
> wdActiveDoc.Close wdDoNotSaveChanges
>
> Note, you do not show that you have declared wdActiveDoc as a document
> object.
>
> --
> Hope this helps.



Re: Starting MSWord Merge from MSAccess by Doug

Doug
Thu Nov 29 22:20:28 PST 2007

In place of

wd.Windows("merge_ad.doc ").Activate
wd.ActiveWindow.Close 0
wdActiveDoc.saveas Filename:="K:\legalper\merged_ad.doc"

use

wdActiveDoc.Close wdDoNotSaveChanges
wd.ActiveDocument.SaveAs "K:\legalper\merged_ad.doc"

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
news:eGhrj0rMIHA.484@TK2MSFTNGP06.phx.gbl...
> In place of
>
> wd.Windows("merge_ad.doc ").Activate
> wd.ActiveWindow.Close 0
>
> use
>
> wdActiveDoc.Close wdDoNotSaveChanges
>
> Note, you do not show that you have declared wdActiveDoc as a document
> object.
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "Kathy Webster" <slickdock@yahoo.com> wrote in message
> news:474f0729$0$2338$4c368faf@roadrunner.com...
>>I am collecting info from an MSAccess record and trying to merge it in
>>Word. I would like this to work with any version of Word that the user may
>>have installed. My MSAccess app will be a runtime app that I will be
>>putting on various machines in different workplaces.
>> Here is the code I am running from MSAccess:
>>
>> Public Function AddressBlock() As Boolean
>>
>> Dim wd As Object
>> Dim wdActiveDoc As Object 'RM: Added this to help ensure that you're
>> 'working on the document you intend to.
>> Dim wdField As Object 'RM: Note the change in name here to avoid
>> 'ambiguity with the Field object in both Word
>> and
>> 'Access. As well, I changed the type, since
>> '(like Word.Application), you have to use late
>> 'binding.
>>
>> Set wd = CreateObject("Word.Application")
>> wd.Visible = True
>>
>> wd.Application.ScreenUpdating = False
>>
>> Set wdActiveDoc = wd.Documents.Open("K:\legalper\merge_ad.doc ",
>> False, False, _
>> False, "", "", False, "", "", 0)
>>
>> With wdActiveDoc.MailMerge
>> .Destination = 0
>> .Execute
>> End With
>> wd.Windows("merge_ad.doc ").Activate
>> wd.ActiveWindow.Close 0
>> 'It bombs here with "Automation error: The object invoked has
>> disconnected from its clients", and the next line is highlighted.
>> 'What I'm trying to do here is open merge_ad.doc, merge it, close
>> merge_ad.doc, then save the
>> 'resulting merged doc as "merged_ad.doc"
>> wdActiveDoc.saveas Filename:="K:\legalper\merged_ad.doc",
>> FileFormat:=0
>>
>> Thanks in advance,
>> Kathy
>>
>
>



Re: Starting MSWord Merge from MSAccess by Kathy

Kathy
Fri Nov 30 09:11:14 PST 2007

Cool, thanks. I had make 1 change to this line:

wdActiveDoc.Close wdDoNotSaveChanges

to

wdActiveDoc.Close , 0

because it didn't understand wdDoNotSaveChanges

One last thing: Now my Word screen is left with "merged_ad.doc" in the
title bar, and the screen is inactive (gray background, no white "sheet of
paper" ready to go). How can I leave Word with no document in the title bar
and a white "Sheet of paper" on the screen?




"Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
news:O2ZbikxMIHA.5988@TK2MSFTNGP02.phx.gbl...
> In place of
>
> wd.Windows("merge_ad.doc ").Activate
> wd.ActiveWindow.Close 0
> wdActiveDoc.saveas Filename:="K:\legalper\merged_ad.doc"
>
> use
>
> wdActiveDoc.Close wdDoNotSaveChanges
> wd.ActiveDocument.SaveAs "K:\legalper\merged_ad.doc"
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
> news:eGhrj0rMIHA.484@TK2MSFTNGP06.phx.gbl...
>> In place of
>>
>> wd.Windows("merge_ad.doc ").Activate
>> wd.ActiveWindow.Close 0
>>
>> use
>>
>> wdActiveDoc.Close wdDoNotSaveChanges
>>
>> Note, you do not show that you have declared wdActiveDoc as a document
>> object.
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>> "Kathy Webster" <slickdock@yahoo.com> wrote in message
>> news:474f0729$0$2338$4c368faf@roadrunner.com...
>>>I am collecting info from an MSAccess record and trying to merge it in
>>>Word. I would like this to work with any version of Word that the user
>>>may have installed. My MSAccess app will be a runtime app that I will be
>>>putting on various machines in different workplaces.
>>> Here is the code I am running from MSAccess:
>>>
>>> Public Function AddressBlock() As Boolean
>>>
>>> Dim wd As Object
>>> Dim wdActiveDoc As Object 'RM: Added this to help ensure that you're
>>> 'working on the document you intend to.
>>> Dim wdField As Object 'RM: Note the change in name here to avoid
>>> 'ambiguity with the Field object in both Word
>>> and
>>> 'Access. As well, I changed the type, since
>>> '(like Word.Application), you have to use late
>>> 'binding.
>>>
>>> Set wd = CreateObject("Word.Application")
>>> wd.Visible = True
>>>
>>> wd.Application.ScreenUpdating = False
>>>
>>> Set wdActiveDoc = wd.Documents.Open("K:\legalper\merge_ad.doc ",
>>> False, False, _
>>> False, "", "", False, "", "", 0)
>>>
>>> With wdActiveDoc.MailMerge
>>> .Destination = 0
>>> .Execute
>>> End With
>>> wd.Windows("merge_ad.doc ").Activate
>>> wd.ActiveWindow.Close 0
>>> 'It bombs here with "Automation error: The object invoked has
>>> disconnected from its clients", and the next line is highlighted.
>>> 'What I'm trying to do here is open merge_ad.doc, merge it, close
>>> merge_ad.doc, then save the
>>> 'resulting merged doc as "merged_ad.doc"
>>> wdActiveDoc.saveas Filename:="K:\legalper\merged_ad.doc",
>>> FileFormat:=0
>>>
>>> Thanks in advance,
>>> Kathy
>>>
>>
>>
>
>



Re: Starting MSWord Merge from MSAccess by Doug

Doug
Fri Nov 30 11:17:40 PST 2007

Earlier in your code, you have turned off ScreenUpdating

Try adding the following at the end.

wd.ScreenUpdating = True
wd.ScreenRefresh
wd.ActiveDocument.Close
wd.Documents.Add

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Kathy Webster" <slickdock@yahoo.com> wrote in message
news:47504432$0$8823$4c368faf@roadrunner.com...
> Cool, thanks. I had make 1 change to this line:
>
> wdActiveDoc.Close wdDoNotSaveChanges
>
> to
>
> wdActiveDoc.Close , 0
>
> because it didn't understand wdDoNotSaveChanges
>
> One last thing: Now my Word screen is left with "merged_ad.doc" in the
> title bar, and the screen is inactive (gray background, no white "sheet of
> paper" ready to go). How can I leave Word with no document in the title
> bar and a white "Sheet of paper" on the screen?
>
>
>
>
> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
> news:O2ZbikxMIHA.5988@TK2MSFTNGP02.phx.gbl...
>> In place of
>>
>> wd.Windows("merge_ad.doc ").Activate
>> wd.ActiveWindow.Close 0
>> wdActiveDoc.saveas Filename:="K:\legalper\merged_ad.doc"
>>
>> use
>>
>> wdActiveDoc.Close wdDoNotSaveChanges
>> wd.ActiveDocument.SaveAs "K:\legalper\merged_ad.doc"
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
>> news:eGhrj0rMIHA.484@TK2MSFTNGP06.phx.gbl...
>>> In place of
>>>
>>> wd.Windows("merge_ad.doc ").Activate
>>> wd.ActiveWindow.Close 0
>>>
>>> use
>>>
>>> wdActiveDoc.Close wdDoNotSaveChanges
>>>
>>> Note, you do not show that you have declared wdActiveDoc as a document
>>> object.
>>>
>>> --
>>> Hope this helps.
>>>
>>> Please reply to the newsgroup unless you wish to avail yourself of my
>>> services on a paid consulting basis.
>>>
>>> Doug Robbins - Word MVP
>>>
>>> "Kathy Webster" <slickdock@yahoo.com> wrote in message
>>> news:474f0729$0$2338$4c368faf@roadrunner.com...
>>>>I am collecting info from an MSAccess record and trying to merge it in
>>>>Word. I would like this to work with any version of Word that the user
>>>>may have installed. My MSAccess app will be a runtime app that I will
>>>>be putting on various machines in different workplaces.
>>>> Here is the code I am running from MSAccess:
>>>>
>>>> Public Function AddressBlock() As Boolean
>>>>
>>>> Dim wd As Object
>>>> Dim wdActiveDoc As Object 'RM: Added this to help ensure that you're
>>>> 'working on the document you intend to.
>>>> Dim wdField As Object 'RM: Note the change in name here to avoid
>>>> 'ambiguity with the Field object in both Word
>>>> and
>>>> 'Access. As well, I changed the type, since
>>>> '(like Word.Application), you have to use late
>>>> 'binding.
>>>>
>>>> Set wd = CreateObject("Word.Application")
>>>> wd.Visible = True
>>>>
>>>> wd.Application.ScreenUpdating = False
>>>>
>>>> Set wdActiveDoc = wd.Documents.Open("K:\legalper\merge_ad.doc ",
>>>> False, False, _
>>>> False, "", "", False, "", "", 0)
>>>>
>>>> With wdActiveDoc.MailMerge
>>>> .Destination = 0
>>>> .Execute
>>>> End With
>>>> wd.Windows("merge_ad.doc ").Activate
>>>> wd.ActiveWindow.Close 0
>>>> 'It bombs here with "Automation error: The object invoked has
>>>> disconnected from its clients", and the next line is highlighted.
>>>> 'What I'm trying to do here is open merge_ad.doc, merge it, close
>>>> merge_ad.doc, then save the
>>>> 'resulting merged doc as "merged_ad.doc"
>>>> wdActiveDoc.saveas Filename:="K:\legalper\merged_ad.doc",
>>>> FileFormat:=0
>>>>
>>>> Thanks in advance,
>>>> Kathy
>>>>
>>>
>>>
>>
>>
>
>



Re: Starting MSWord Merge from MSAccess by Kathy

Kathy
Fri Nov 30 14:52:46 PST 2007

You da bomb...Thanks!
One last question...I hope...
How do I modify this line you gave me, so that "merged_ad.doc" doesn't show
up on the recently edited docs list?

wd.ActiveDocument.SaveAs "K:\legalper\merged_ad.doc"

"Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
news:OMl6yW4MIHA.5160@TK2MSFTNGP05.phx.gbl...
> Earlier in your code, you have turned off ScreenUpdating
>
> Try adding the following at the end.
>
> wd.ScreenUpdating = True
> wd.ScreenRefresh
> wd.ActiveDocument.Close
> wd.Documents.Add
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "Kathy Webster" <slickdock@yahoo.com> wrote in message
> news:47504432$0$8823$4c368faf@roadrunner.com...
>> Cool, thanks. I had make 1 change to this line:
>>
>> wdActiveDoc.Close wdDoNotSaveChanges
>>
>> to
>>
>> wdActiveDoc.Close , 0
>>
>> because it didn't understand wdDoNotSaveChanges
>>
>> One last thing: Now my Word screen is left with "merged_ad.doc" in the
>> title bar, and the screen is inactive (gray background, no white "sheet
>> of paper" ready to go). How can I leave Word with no document in the
>> title bar and a white "Sheet of paper" on the screen?
>>
>>
>>
>>
>> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
>> news:O2ZbikxMIHA.5988@TK2MSFTNGP02.phx.gbl...
>>> In place of
>>>
>>> wd.Windows("merge_ad.doc ").Activate
>>> wd.ActiveWindow.Close 0
>>> wdActiveDoc.saveas Filename:="K:\legalper\merged_ad.doc"
>>>
>>> use
>>>
>>> wdActiveDoc.Close wdDoNotSaveChanges
>>> wd.ActiveDocument.SaveAs "K:\legalper\merged_ad.doc"
>>>
>>> --
>>> Hope this helps.
>>>
>>> Please reply to the newsgroup unless you wish to avail yourself of my
>>> services on a paid consulting basis.
>>>
>>> Doug Robbins - Word MVP
>>>
>>> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
>>> news:eGhrj0rMIHA.484@TK2MSFTNGP06.phx.gbl...
>>>> In place of
>>>>
>>>> wd.Windows("merge_ad.doc ").Activate
>>>> wd.ActiveWindow.Close 0
>>>>
>>>> use
>>>>
>>>> wdActiveDoc.Close wdDoNotSaveChanges
>>>>
>>>> Note, you do not show that you have declared wdActiveDoc as a document
>>>> object.
>>>>
>>>> --
>>>> Hope this helps.
>>>>
>>>> Please reply to the newsgroup unless you wish to avail yourself of my
>>>> services on a paid consulting basis.
>>>>
>>>> Doug Robbins - Word MVP
>>>>
>>>> "Kathy Webster" <slickdock@yahoo.com> wrote in message
>>>> news:474f0729$0$2338$4c368faf@roadrunner.com...
>>>>>I am collecting info from an MSAccess record and trying to merge it in
>>>>>Word. I would like this to work with any version of Word that the user
>>>>>may have installed. My MSAccess app will be a runtime app that I will
>>>>>be putting on various machines in different workplaces.
>>>>> Here is the code I am running from MSAccess:
>>>>>
>>>>> Public Function AddressBlock() As Boolean
>>>>>
>>>>> Dim wd As Object
>>>>> Dim wdActiveDoc As Object 'RM: Added this to help ensure that
>>>>> you're
>>>>> 'working on the document you intend to.
>>>>> Dim wdField As Object 'RM: Note the change in name here to avoid
>>>>> 'ambiguity with the Field object in both Word
>>>>> and
>>>>> 'Access. As well, I changed the type, since
>>>>> '(like Word.Application), you have to use
>>>>> late
>>>>> 'binding.
>>>>>
>>>>> Set wd = CreateObject("Word.Application")
>>>>> wd.Visible = True
>>>>>
>>>>> wd.Application.ScreenUpdating = False
>>>>>
>>>>> Set wdActiveDoc = wd.Documents.Open("K:\legalper\merge_ad.doc ",
>>>>> False, False, _
>>>>> False, "", "", False, "", "", 0)
>>>>>
>>>>> With wdActiveDoc.MailMerge
>>>>> .Destination = 0
>>>>> .Execute
>>>>> End With
>>>>> wd.Windows("merge_ad.doc ").Activate
>>>>> wd.ActiveWindow.Close 0
>>>>> 'It bombs here with "Automation error: The object invoked has
>>>>> disconnected from its clients", and the next line is highlighted.
>>>>> 'What I'm trying to do here is open merge_ad.doc, merge it, close
>>>>> merge_ad.doc, then save the
>>>>> 'resulting merged doc as "merged_ad.doc"
>>>>> wdActiveDoc.saveas Filename:="K:\legalper\merged_ad.doc",
>>>>> FileFormat:=0
>>>>>
>>>>> Thanks in advance,
>>>>> Kathy
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Re: Starting MSWord Merge from MSAccess by Doug

Doug
Fri Nov 30 17:42:17 PST 2007

Use

wd.ActiveDocument.SaveAs "K:\legalper\merged_ad.doc", SaveToRecentFiles:
= False

or, as you seem to have had troubled with using named parameters, you may
need to use

wd.ActiveDocument.SaveAs "K:\legalper\merged_ad.doc","","","", False



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Kathy Webster" <slickdock@yahoo.com> wrote in message
news:47509462$0$16483$4c368faf@roadrunner.com...
> You da bomb...Thanks!
> One last question...I hope...
> How do I modify this line you gave me, so that "merged_ad.doc" doesn't
> show up on the recently edited docs list?
>
> wd.ActiveDocument.SaveAs "K:\legalper\merged_ad.doc"
>
> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
> news:OMl6yW4MIHA.5160@TK2MSFTNGP05.phx.gbl...
>> Earlier in your code, you have turned off ScreenUpdating
>>
>> Try adding the following at the end.
>>
>> wd.ScreenUpdating = True
>> wd.ScreenRefresh
>> wd.ActiveDocument.Close
>> wd.Documents.Add
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>> "Kathy Webster" <slickdock@yahoo.com> wrote in message
>> news:47504432$0$8823$4c368faf@roadrunner.com...
>>> Cool, thanks. I had make 1 change to this line:
>>>
>>> wdActiveDoc.Close wdDoNotSaveChanges
>>>
>>> to
>>>
>>> wdActiveDoc.Close , 0
>>>
>>> because it didn't understand wdDoNotSaveChanges
>>>
>>> One last thing: Now my Word screen is left with "merged_ad.doc" in the
>>> title bar, and the screen is inactive (gray background, no white "sheet
>>> of paper" ready to go). How can I leave Word with no document in the
>>> title bar and a white "Sheet of paper" on the screen?
>>>
>>>
>>>
>>>
>>> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
>>> news:O2ZbikxMIHA.5988@TK2MSFTNGP02.phx.gbl...
>>>> In place of
>>>>
>>>> wd.Windows("merge_ad.doc ").Activate
>>>> wd.ActiveWindow.Close 0
>>>> wdActiveDoc.saveas Filename:="K:\legalper\merged_ad.doc"
>>>>
>>>> use
>>>>
>>>> wdActiveDoc.Close wdDoNotSaveChanges
>>>> wd.ActiveDocument.SaveAs "K:\legalper\merged_ad.doc"
>>>>
>>>> --
>>>> Hope this helps.
>>>>
>>>> Please reply to the newsgroup unless you wish to avail yourself of my
>>>> services on a paid consulting basis.
>>>>
>>>> Doug Robbins - Word MVP
>>>>
>>>> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
>>>> news:eGhrj0rMIHA.484@TK2MSFTNGP06.phx.gbl...
>>>>> In place of
>>>>>
>>>>> wd.Windows("merge_ad.doc ").Activate
>>>>> wd.ActiveWindow.Close 0
>>>>>
>>>>> use
>>>>>
>>>>> wdActiveDoc.Close wdDoNotSaveChanges
>>>>>
>>>>> Note, you do not show that you have declared wdActiveDoc as a document
>>>>> object.
>>>>>
>>>>> --
>>>>> Hope this helps.
>>>>>
>>>>> Please reply to the newsgroup unless you wish to avail yourself of my
>>>>> services on a paid consulting basis.
>>>>>
>>>>> Doug Robbins - Word MVP
>>>>>
>>>>> "Kathy Webster" <slickdock@yahoo.com> wrote in message
>>>>> news:474f0729$0$2338$4c368faf@roadrunner.com...
>>>>>>I am collecting info from an MSAccess record and trying to merge it in
>>>>>>Word. I would like this to work with any version of Word that the user
>>>>>>may have installed. My MSAccess app will be a runtime app that I will
>>>>>>be putting on various machines in different workplaces.
>>>>>> Here is the code I am running from MSAccess:
>>>>>>
>>>>>> Public Function AddressBlock() As Boolean
>>>>>>
>>>>>> Dim wd As Object
>>>>>> Dim wdActiveDoc As Object 'RM: Added this to help ensure that
>>>>>> you're
>>>>>> 'working on the document you intend to.
>>>>>> Dim wdField As Object 'RM: Note the change in name here to avoid
>>>>>> 'ambiguity with the Field object in both
>>>>>> Word and
>>>>>> 'Access. As well, I changed the type, since
>>>>>> '(like Word.Application), you have to use
>>>>>> late
>>>>>> 'binding.
>>>>>>
>>>>>> Set wd = CreateObject("Word.Application")
>>>>>> wd.Visible = True
>>>>>>
>>>>>> wd.Application.ScreenUpdating = False
>>>>>>
>>>>>> Set wdActiveDoc = wd.Documents.Open("K:\legalper\merge_ad.doc ",
>>>>>> False, False, _
>>>>>> False, "", "", False, "", "", 0)
>>>>>>
>>>>>> With wdActiveDoc.MailMerge
>>>>>> .Destination = 0
>>>>>> .Execute
>>>>>> End With
>>>>>> wd.Windows("merge_ad.doc ").Activate
>>>>>> wd.ActiveWindow.Close 0
>>>>>> 'It bombs here with "Automation error: The object invoked has
>>>>>> disconnected from its clients", and the next line is highlighted.
>>>>>> 'What I'm trying to do here is open merge_ad.doc, merge it, close
>>>>>> merge_ad.doc, then save the
>>>>>> 'resulting merged doc as "merged_ad.doc"
>>>>>> wdActiveDoc.saveas Filename:="K:\legalper\merged_ad.doc",
>>>>>> FileFormat:=0
>>>>>>
>>>>>> Thanks in advance,
>>>>>> Kathy
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Re: Starting MSWord Merge from MSAccess by Kathy

Kathy
Mon Dec 03 09:48:33 PST 2007

Unfortunately, it didn't like either of those, but I messed with it, and it
likes:
wd.ActiveDocument.SaveAs "K:\legalper\merged_ad.doc", _
0, False, "", False, "", False, False, False, False, False

Thank you!


"Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
news:%2353kvt7MIHA.4480@TK2MSFTNGP06.phx.gbl...
> Use
>
> wd.ActiveDocument.SaveAs "K:\legalper\merged_ad.doc",
> SaveToRecentFiles: = False
>
> or, as you seem to have had troubled with using named parameters, you may
> need to use
>
> wd.ActiveDocument.SaveAs "K:\legalper\merged_ad.doc","","","", False
>
>
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "Kathy Webster" <slickdock@yahoo.com> wrote in message
> news:47509462$0$16483$4c368faf@roadrunner.com...
>> You da bomb...Thanks!
>> One last question...I hope...
>> How do I modify this line you gave me, so that "merged_ad.doc" doesn't
>> show up on the recently edited docs list?
>>
>> wd.ActiveDocument.SaveAs "K:\legalper\merged_ad.doc"
>>
>> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
>> news:OMl6yW4MIHA.5160@TK2MSFTNGP05.phx.gbl...
>>> Earlier in your code, you have turned off ScreenUpdating
>>>
>>> Try adding the following at the end.
>>>
>>> wd.ScreenUpdating = True
>>> wd.ScreenRefresh
>>> wd.ActiveDocument.Close
>>> wd.Documents.Add
>>>
>>> --
>>> Hope this helps.
>>>
>>> Please reply to the newsgroup unless you wish to avail yourself of my
>>> services on a paid consulting basis.
>>>
>>> Doug Robbins - Word MVP
>>>
>>> "Kathy Webster" <slickdock@yahoo.com> wrote in message
>>> news:47504432$0$8823$4c368faf@roadrunner.com...
>>>> Cool, thanks. I had make 1 change to this line:
>>>>
>>>> wdActiveDoc.Close wdDoNotSaveChanges
>>>>
>>>> to
>>>>
>>>> wdActiveDoc.Close , 0
>>>>
>>>> because it didn't understand wdDoNotSaveChanges
>>>>
>>>> One last thing: Now my Word screen is left with "merged_ad.doc" in the
>>>> title bar, and the screen is inactive (gray background, no white "sheet
>>>> of paper" ready to go). How can I leave Word with no document in the
>>>> title bar and a white "Sheet of paper" on the screen?
>>>>
>>>>
>>>>
>>>>
>>>> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
>>>> news:O2ZbikxMIHA.5988@TK2MSFTNGP02.phx.gbl...
>>>>> In place of
>>>>>
>>>>> wd.Windows("merge_ad.doc ").Activate
>>>>> wd.ActiveWindow.Close 0
>>>>> wdActiveDoc.saveas Filename:="K:\legalper\merged_ad.doc"
>>>>>
>>>>> use
>>>>>
>>>>> wdActiveDoc.Close wdDoNotSaveChanges
>>>>> wd.ActiveDocument.SaveAs "K:\legalper\merged_ad.doc"
>>>>>
>>>>> --
>>>>> Hope this helps.
>>>>>
>>>>> Please reply to the newsgroup unless you wish to avail yourself of my
>>>>> services on a paid consulting basis.
>>>>>
>>>>> Doug Robbins - Word MVP
>>>>>
>>>>> "Doug Robbins - Word MVP" <dkr@REMOVECAPSmvps.org> wrote in message
>>>>> news:eGhrj0rMIHA.484@TK2MSFTNGP06.phx.gbl...
>>>>>> In place of
>>>>>>
>>>>>> wd.Windows("merge_ad.doc ").Activate
>>>>>> wd.ActiveWindow.Close 0
>>>>>>
>>>>>> use
>>>>>>
>>>>>> wdActiveDoc.Close wdDoNotSaveChanges
>>>>>>
>>>>>> Note, you do not show that you have declared wdActiveDoc as a
>>>>>> document object.
>>>>>>
>>>>>> --
>>>>>> Hope this helps.
>>>>>>
>>>>>> Please reply to the newsgroup unless you wish to avail yourself of my
>>>>>> services on a paid consulting basis.
>>>>>>
>>>>>> Doug Robbins - Word MVP
>>>>>>
>>>>>> "Kathy Webster" <slickdock@yahoo.com> wrote in message
>>>>>> news:474f0729$0$2338$4c368faf@roadrunner.com...
>>>>>>>I am collecting info from an MSAccess record and trying to merge it
>>>>>>>in Word. I would like this to work with any version of Word that the
>>>>>>>user may have installed. My MSAccess app will be a runtime app that
>>>>>>>I will be putting on various machines in different workplaces.
>>>>>>> Here is the code I am running from MSAccess:
>>>>>>>
>>>>>>> Public Function AddressBlock() As Boolean
>>>>>>>
>>>>>>> Dim wd As Object
>>>>>>> Dim wdActiveDoc As Object 'RM: Added this to help ensure that
>>>>>>> you're
>>>>>>> 'working on the document you intend to.
>>>>>>> Dim wdField As Object 'RM: Note the change in name here to avoid
>>>>>>> 'ambiguity with the Field object in both
>>>>>>> Word and
>>>>>>> 'Access. As well, I changed the type,
>>>>>>> since
>>>>>>> '(like Word.Application), you have to use
>>>>>>> late
>>>>>>> 'binding.
>>>>>>>
>>>>>>> Set wd = CreateObject("Word.Application")
>>>>>>> wd.Visible = True
>>>>>>>
>>>>>>> wd.Application.ScreenUpdating = False
>>>>>>>
>>>>>>> Set wdActiveDoc = wd.Documents.Open("K:\legalper\merge_ad.doc ",
>>>>>>> False, False, _
>>>>>>> False, "", "", False, "", "", 0)
>>>>>>>
>>>>>>> With wdActiveDoc.MailMerge
>>>>>>> .Destination = 0
>>>>>>> .Execute
>>>>>>> End With
>>>>>>> wd.Windows("merge_ad.doc ").Activate
>>>>>>> wd.ActiveWindow.Close 0
>>>>>>> 'It bombs here with "Automation error: The object invoked has
>>>>>>> disconnected from its clients", and the next line is highlighted.
>>>>>>> 'What I'm trying to do here is open merge_ad.doc, merge it, close
>>>>>>> merge_ad.doc, then save the
>>>>>>> 'resulting merged doc as "merged_ad.doc"
>>>>>>> wdActiveDoc.saveas Filename:="K:\legalper\merged_ad.doc",
>>>>>>> FileFormat:=0
>>>>>>>
>>>>>>> Thanks in advance,
>>>>>>> Kathy
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Adding to recent files list by Kathy

Kathy
Mon Dec 03 11:53:27 PST 2007

On a related note,
Now that I'm starting to work with this other similar part of the code
(except this is opening the doc, rather than saving as...), I have found
that even though I think I have specified to leave merge_ad.doc off of the
Recently edited files list, it's still showing up:

Public Function AddressBlock() As Boolean

Dim wd As Object
Dim wdActiveDoc As Object 'RM: Added this to help ensure that you're
'working on the document you intend to.
Dim wdField As Object 'RM: Note the change in name here to avoid
'ambiguity with the Field object in both Word and
'Access. As well, I changed the type, since
'(like Word.Application), you have to use late
'binding.

Set wd = CreateObject("Word.Application")
wd.Visible = True

wd.Application.ScreenUpdating = False

Set wdActiveDoc = wd.Documents.Open("K:\legalper\merge_ad.doc ", False,
False, False, "", "", False, "", "", 0)

Can anyone figure out why?



Re: Adding to recent files list by Kathy

Kathy
Tue Dec 04 17:19:08 PST 2007

Anyone??

"Kathy Webster" <slickdock@yahoo.com> wrote in message
news:47545ecb$0$9868$4c368faf@roadrunner.com...
> On a related note,
> Now that I'm starting to work with this other similar part of the code
> (except this is opening the doc, rather than saving as...), I have found
> that even though I think I have specified to leave merge_ad.doc off of the
> Recently edited files list, it's still showing up:
>
> Public Function AddressBlock() As Boolean
>
> Dim wd As Object
> Dim wdActiveDoc As Object 'RM: Added this to help ensure that you're
> 'working on the document you intend to.
> Dim wdField As Object 'RM: Note the change in name here to avoid
> 'ambiguity with the Field object in both Word and
> 'Access. As well, I changed the type, since
> '(like Word.Application), you have to use late
> 'binding.
>
> Set wd = CreateObject("Word.Application")
> wd.Visible = True
>
> wd.Application.ScreenUpdating = False
>
> Set wdActiveDoc = wd.Documents.Open("K:\legalper\merge_ad.doc ", False,
> False, False, "", "", False, "", "", 0)
>
> Can anyone figure out why?
>