(Msg. 9) Posted: Fri Aug 22, 2008 12:19 am
Post subject: Re: Word mailmerge - Visual Basic experts please help! [Login to view extended thread Info.] Archived from groups: microsoft>public>word>mailmerge>fields (more info?)
That is probably because the Word Object library has not been referenced via
the Tools|References option in Access VBA. However, the original author may
have avoided that deliberately because when you reference a library, the
reference is to a specific version of Word.
You can typically work around that using the following instead (you just
don't see the autocomplete Help in the VBA editor that you would otherwise
get)
"Murray Muspratt-Rouse" <Murray.Muspratt-Rouse.2f39f0e.DeleteThis@wordbanter.com> wrote
in message news:Murray.Muspratt-Rouse.2f39f0e@wordbanter.com...
>
> Thank you Doug for referring me to Peter Jamieson's advice. I have
> immediately run in to a problem - it does not like 'objMMMD As
> Word.Document' telling me 'User-defined type not defined' and
> suggesting that it might be in a properly registered object or type
> library. Did I misunderstand Peter's advice? Was I meant to change
> objMMMD to something else?
>
> Murray
>
> Doug Robbins - Word MVP;359552 Wrote:
>> Actually, I did know what the code was doing, but did not understand
>> why.
>>
>> However, I suggest that you follow the advice given by Peter Jamieson
>> and
>> use
>>
>> Dim objMMMD As Word.Document
>> '
>> '
>> '
>> Set objMMMD = objApp.Documents.Open FileName:=strDocName, 'etc.
>> '
>> '
>> '
>> ' then when you want to close the mail merge main document, instead of
>> having to
>> ' work out which window it is in, you can do
>>
>> objMMMD.Close SaveChanges:=False
>> '
>> ' then
>>
>> Set objMMMD = Nothing
>>
>>
>> --
>> 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
>>
>> "Murray Muspratt-Rouse" Murray.Muspratt-Rouse.2f24d94.DeleteThis@wordbanter.com
>> wrote
>> in message
>> news:Murray.Muspratt-Rouse.2f24d94@wordbanter.com...[color=blue][i]
>>
>> I agree with Doug about the code he does not understand - since I am
>> not
>> the original author of this code and do not speak VBA any way I have
>> been struggling to find my way to add new function to the
>> application.
>>
>> The merge document is selected by the user from an Access table in
>> which the full path to the file is stored, so what the code that we
>> cannot understand does is to strip off the path to the document from
>> strDocName: -
>> Dim intSplitName As Integer
>> Dim intLength As Integer
>> intLength = Len(strDocName)
>> intSplitName = InStrRev(strDocName, "\", , vbTextCompare)
>> strDocName = Right(strDocName, intLength - intSplitName)
>>
>>
>> objApp.Windows(strDocName).Activate
>> objApp.ActiveWindow.Close SaveChanges:=wdDoNotSaveChanges
>> So perhaps what the last line does is to shut the new document, since
>> the original merge document is displayed. I have tried commenting out
>> this code but that only results in an error. I will try changing
>> ActiveWindow in the last line to strDocName!
>>
>> Many thanks for your time and trouble
>>
>> Murray
>> murray.DeleteThis@geodesia.com
>
>
> +-------------------------------------------------------------------+
> +-------------------------------------------------------------------+
>
>
>
> --
> Murray Muspratt-Rouse
(Msg. 10) Posted: Fri Aug 22, 2008 9:48 am
Post subject: Re: Word mailmerge - Visual Basic experts please help! [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
I am very grateful to Peter for his advice - this morning I realised
that I should have googled objMMMD. When I did that I found some of his
postings on the web and started looking for Microsoft Office 12.0 Object
Library, Trying to reference it showed it to be missing, so I tried to
find its name and location. What I saw was cut off at c:\Program
Files\Microsoft Office\Office 12\M - and I could not make the pop up
any wider!
I have tried Dim objMMMD As Object - the result was a compile error
with a syntax error on Set objMMMD = objApp.Documents.Open
FileName:=strDocName etc. I must locate the Object Library and
regioster it, I think.
Murray
Peter Jamieson;359803 Wrote:
> That is probably because the Word Object library has not been referenced > via
> the Tools|References option in Access VBA. However, the original author > may
> have avoided that deliberately because when you reference a library, > the
> reference is to a specific version of Word.
>
> You can typically work around that using the following instead (you > just
> don't see the autocomplete Help in the VBA editor that you would > otherwise
> get)
>
> Dim objMMMD As Object
>
> --
> Peter Jamieson
> http://tips.pjmsn.me.uk >
> "Murray Muspratt-Rouse" Murray.Muspratt-Rouse.2f39f0e.RemoveThis@wordbanter.com > wrote
> in message news:Murray.Muspratt-Rouse.2f39f0e@wordbanter.com...-
>
> Thank you Doug for referring me to Peter Jamieson's advice. I have
> immediately run in to a problem - it does not like 'objMMMD As
> Word.Document' telling me 'User-defined type not defined' and
> suggesting that it might be in a properly registered object or type
> library. Did I misunderstand Peter's advice? Was I meant to change
> objMMMD to something else?
>
> Murray
>
> Doug Robbins - Word MVP;359552 Wrote:-
> Actually, I did know what the code was doing, but did not understand
> why.
>
> However, I suggest that you follow the advice given by Peter Jamieson
> and
> use
>
> Dim objMMMD As Word.Document
> '
> '
> '
> Set objMMMD = objApp.Documents.Open FileName:=strDocName, 'etc.
> '
> '
> '
> ' then when you want to close the mail merge main document, instead > of
> having to
> ' work out which window it is in, you can do
>
> objMMMD.Close SaveChanges:=False
> '
> ' then
>
> Set objMMMD = Nothing
>
>
> --
> 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
>
> "Murray Muspratt-Rouse" Murray.Muspratt-Rouse.2f24d94.RemoveThis@wordbanter.com
> wrote
> in message
> news:Murray.Muspratt-Rouse.2f24d94@wordbanter.com...[color=blue][i]
>
> I agree with Doug about the code he does not understand - since I am
> not
> the original author of this code and do not speak VBA any way I have
> been struggling to find my way to add new function to the
> application.
>
> The merge document is selected by the user from an Access table in
> which the full path to the file is stored, so what the code that we
> cannot understand does is to strip off the path to the document from
> strDocName: -
> Dim intSplitName As Integer
> Dim intLength As Integer
> intLength = Len(strDocName)
> intSplitName = InStrRev(strDocName, "\", , vbTextCompare)
> strDocName = Right(strDocName, intLength - intSplitName)
>
>
> objApp.Windows(strDocName).Activate
> objApp.ActiveWindow.Close SaveChanges:=wdDoNotSaveChanges
> So perhaps what the last line does is to shut the new document, since
> the original merge document is displayed. I have tried commenting out
> this code but that only results in an error. I will try changing
> ActiveWindow in the last line to strDocName!
>
> Many thanks for your time and trouble
>
> Murray
> murray.RemoveThis@geodesia.com-
>
>
> +-------------------------------------------------------------------+
> +-------------------------------------------------------------------+
>
>
>
> --
> Murray Muspratt-Rouse -
(Msg. 11) Posted: Fri Aug 22, 2008 1:05 pm
Post subject: Re: Word mailmerge - Visual Basic experts please help! [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
My apologies- the syntax for the Open has to change to the "function" style
where the parameter list is surrounded by braces, e.g.
Set objMMMD = objApp.Documents.Open(FileName:=strDocName)
"Murray Muspratt-Rouse" <Murray.Muspratt-Rouse.2f447cd DeleteThis @wordbanter.com> wrote
in message news:Murray.Muspratt-Rouse.2f447cd@wordbanter.com...
>
> I am very grateful to Peter for his advice - this morning I realised
> that I should have googled objMMMD. When I did that I found some of his
> postings on the web and started looking for Microsoft Office 12.0 Object
> Library, Trying to reference it showed it to be missing, so I tried to
> find its name and location. What I saw was cut off at c:\Program
> Files\Microsoft Office\Office 12\M - and I could not make the pop up
> any wider!
>
> I have tried Dim objMMMD As Object - the result was a compile error
> with a syntax error on Set objMMMD = objApp.Documents.Open
> FileName:=strDocName etc. I must locate the Object Library and
> regioster it, I think.
>
> Murray
>
> Peter Jamieson;359803 Wrote:
>> That is probably because the Word Object library has not been referenced
>> via
>> the Tools|References option in Access VBA. However, the original author
>> may
>> have avoided that deliberately because when you reference a library,
>> the
>> reference is to a specific version of Word.
>>
>> You can typically work around that using the following instead (you
>> just
>> don't see the autocomplete Help in the VBA editor that you would
>> otherwise
>> get)
>>
>> Dim objMMMD As Object
>>
>> --
>> Peter Jamieson
>> http://tips.pjmsn.me.uk >>
>> "Murray Muspratt-Rouse" Murray.Muspratt-Rouse.2f39f0e DeleteThis @wordbanter.com
>> wrote
>> in message news:Murray.Muspratt-Rouse.2f39f0e@wordbanter.com...-
>>
>> Thank you Doug for referring me to Peter Jamieson's advice. I have
>> immediately run in to a problem - it does not like 'objMMMD As
>> Word.Document' telling me 'User-defined type not defined' and
>> suggesting that it might be in a properly registered object or type
>> library. Did I misunderstand Peter's advice? Was I meant to change
>> objMMMD to something else?
>>
>> Murray
>>
>> Doug Robbins - Word MVP;359552 Wrote:-
>> Actually, I did know what the code was doing, but did not understand
>> why.
>>
>> However, I suggest that you follow the advice given by Peter Jamieson
>> and
>> use
>>
>> Dim objMMMD As Word.Document
>> '
>> '
>> '
>> Set objMMMD = objApp.Documents.Open FileName:=strDocName, 'etc.
>> '
>> '
>> '
>> ' then when you want to close the mail merge main document, instead
>> of
>> having to
>> ' work out which window it is in, you can do
>>
>> objMMMD.Close SaveChanges:=False
>> '
>> ' then
>>
>> Set objMMMD = Nothing
>>
>>
>> --
>> 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
>>
>> "Murray Muspratt-Rouse" Murray.Muspratt-Rouse.2f24d94 DeleteThis @wordbanter.com
>> wrote
>> in message
>> news:Murray.Muspratt-Rouse.2f24d94@wordbanter.com...[color=blue][i]
>>
>> I agree with Doug about the code he does not understand - since I am
>> not
>> the original author of this code and do not speak VBA any way I have
>> been struggling to find my way to add new function to the
>> application.
>>
>> The merge document is selected by the user from an Access table in
>> which the full path to the file is stored, so what the code that we
>> cannot understand does is to strip off the path to the document from
>> strDocName: -
>> Dim intSplitName As Integer
>> Dim intLength As Integer
>> intLength = Len(strDocName)
>> intSplitName = InStrRev(strDocName, "\", , vbTextCompare)
>> strDocName = Right(strDocName, intLength - intSplitName)
>>
>>
>> objApp.Windows(strDocName).Activate
>> objApp.ActiveWindow.Close SaveChanges:=wdDoNotSaveChanges
>> So perhaps what the last line does is to shut the new document, since
>> the original merge document is displayed. I have tried commenting out
>> this code but that only results in an error. I will try changing
>> ActiveWindow in the last line to strDocName!
>>
>> Many thanks for your time and trouble
>>
>> Murray
>> murray DeleteThis @geodesia.com-
>>
>>
>> +-------------------------------------------------------------------+
>> +-------------------------------------------------------------------+
>>
>>
>>
>> --
>> Murray Muspratt-Rouse -
>
>
> +-------------------------------------------------------------------+
> +-------------------------------------------------------------------+
>
>
>
> --
> Murray Muspratt-Rouse
(Msg. 12) Posted: Fri Aug 22, 2008 5:16 pm
Post subject: Re: Word mailmerge - Visual Basic experts please help! [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
I think I have overcome the Tools/References problem, but now I have
another one: - I get an compile error message telling me that End of
Statement was expected, highlighting FileName in the statement to which
I have added 'Set objMMMD ='
Peter Jamieson;359803 Wrote:
> That is probably because the Word Object library has not been referenced > via
> the Tools|References option in Access VBA. However, the original author > may
> have avoided that deliberately because when you reference a library, > the
> reference is to a specific version of Word.
>
> You can typically work around that using the following instead (you > just
> don't see the autocomplete Help in the VBA editor that you would > otherwise
> get)
>
> Dim objMMMD As Object
>
> --
> Peter Jamieson
> http://tips.pjmsn.me.uk >
> "Murray Muspratt-Rouse" Murray.Muspratt-Rouse.2f39f0e.RemoveThis@wordbanter.com > wrote
> in message news:Murray.Muspratt-Rouse.2f39f0e@wordbanter.com...-
>
> Thank you Doug for referring me to Peter Jamieson's advice. I have
> immediately run in to a problem - it does not like 'objMMMD As
> Word.Document' telling me 'User-defined type not defined' and
> suggesting that it might be in a properly registered object or type
> library. Did I misunderstand Peter's advice? Was I meant to change
> objMMMD to something else?
>
> Murray
>
> Doug Robbins - Word MVP;359552 Wrote:-
> Actually, I did know what the code was doing, but did not understand
> why.
>
> However, I suggest that you follow the advice given by Peter Jamieson
> and
> use
>
> Dim objMMMD As Word.Document
> '
> '
> '
> Set objMMMD = objApp.Documents.Open FileName:=strDocName, 'etc.
> '
> '
> '
> ' then when you want to close the mail merge main document, instead > of
> having to
> ' work out which window it is in, you can do
>
> objMMMD.Close SaveChanges:=False
> '
> ' then
>
> Set objMMMD = Nothing
>
>
> --
> 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
>
> "Murray Muspratt-Rouse" Murray.Muspratt-Rouse.2f24d94.RemoveThis@wordbanter.com
> wrote
> in message
> news:Murray.Muspratt-Rouse.2f24d94@wordbanter.com...[color=blue][i]
>
> I agree with Doug about the code he does not understand - since I am
> not
> the original author of this code and do not speak VBA any way I have
> been struggling to find my way to add new function to the
> application.
>
> The merge document is selected by the user from an Access table in
> which the full path to the file is stored, so what the code that we
> cannot understand does is to strip off the path to the document from
> strDocName: -
> Dim intSplitName As Integer
> Dim intLength As Integer
> intLength = Len(strDocName)
> intSplitName = InStrRev(strDocName, "\", , vbTextCompare)
> strDocName = Right(strDocName, intLength - intSplitName)
>
>
> objApp.Windows(strDocName).Activate
> objApp.ActiveWindow.Close SaveChanges:=wdDoNotSaveChanges
> So perhaps what the last line does is to shut the new document, since
> the original merge document is displayed. I have tried commenting out
> this code but that only results in an error. I will try changing
> ActiveWindow in the last line to strDocName!
>
> Many thanks for your time and trouble
>
> Murray
> murray.RemoveThis@geodesia.com-
>
>
> +-------------------------------------------------------------------+
> +-------------------------------------------------------------------+
>
>
>
> --
> Murray Muspratt-Rouse -
(Msg. 13) Posted: Fri Aug 22, 2008 7:39 pm
Post subject: Re: Word mailmerge - Visual Basic experts please help! [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
This time at execution the error message on "Dim objMMMD As
Word.Document" was 'User-defined type not defined'. Does this mean I am
missing something else? A 'type' library?
Murray
Peter Jamieson;359914 Wrote:
> My apologies- the syntax for the Open has to change to the "function"
> style
> where the parameter list is surrounded by braces, e.g.
>
> Set objMMMD = objApp.Documents.Open(FileName:=strDocName)
>
>
> --
> Peter Jamieson
> http://tips.pjmsn.me.uk >
> "Murray Muspratt-Rouse" Murray.Muspratt-Rouse.2f447cd.DeleteThis@wordbanter.com
> wrote
> in message news:Murray.Muspratt-Rouse.2f447cd@wordbanter.com...-
>
> I am very grateful to Peter for his advice - this morning I realised
> that I should have googled objMMMD. When I did that I found some of
> his
> postings on the web and started looking for Microsoft Office 12.0
> Object
> Library, Trying to reference it showed it to be missing, so I tried
> to
> find its name and location. What I saw was cut off at c:\Program
> Files\Microsoft Office\Office 12\M - and I could not make the pop up
> any wider!
>
> I have tried Dim objMMMD As Object - the result was a compile error
> with a syntax error on Set objMMMD = objApp.Documents.Open
> FileName:=strDocName etc. I must locate the Object Library and
> regioster it, I think.
>
> Murray
>
> Peter Jamieson;359803 Wrote:-
> That is probably because the Word Object library has not been
> referenced
> via
> the Tools|References option in Access VBA. However, the original
> author
> may
> have avoided that deliberately because when you reference a library,
> the
> reference is to a specific version of Word.
>
> You can typically work around that using the following instead (you
> just
> don't see the autocomplete Help in the VBA editor that you would
> otherwise
> get)
>
> Dim objMMMD As Object
>
> --
> Peter Jamieson
> http://tips.pjmsn.me.uk >
> "Murray Muspratt-Rouse" Murray.Muspratt-Rouse.2f39f0e.DeleteThis@wordbanter.com
> wrote
> in message news:Murray.Muspratt-Rouse.2f39f0e@wordbanter.com...-
>
> Thank you Doug for referring me to Peter Jamieson's advice. I have
> immediately run in to a problem - it does not like 'objMMMD As
> Word.Document' telling me 'User-defined type not defined' and
> suggesting that it might be in a properly registered object or type
> library. Did I misunderstand Peter's advice? Was I meant to change
> objMMMD to something else?
>
> Murray
>
> Doug Robbins - Word MVP;359552 Wrote:-
> Actually, I did know what the code was doing, but did not understand
> why.
>
> However, I suggest that you follow the advice given by Peter Jamieson
> and
> use
>
> Dim objMMMD As Word.Document
> '
> '
> '
> Set objMMMD = objApp.Documents.Open FileName:=strDocName, 'etc.
> '
> '
> '
> ' then when you want to close the mail merge main document, instead
> of
> having to
> ' work out which window it is in, you can do
>
> objMMMD.Close SaveChanges:=False
> '
> ' then
>
> Set objMMMD = Nothing
>
>
> --
> 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
>
> "Murray Muspratt-Rouse" Murray.Muspratt-Rouse.2f24d94.DeleteThis@wordbanter.com
> wrote
> in message
> news:Murray.Muspratt-Rouse.2f24d94@wordbanter.com...[color=blue][i]
>
> I agree with Doug about the code he does not understand - since I am
> not
> the original author of this code and do not speak VBA any way I have
> been struggling to find my way to add new function to the
> application.
>
> The merge document is selected by the user from an Access table in
> which the full path to the file is stored, so what the code that we
> cannot understand does is to strip off the path to the document from
> strDocName: -
> Dim intSplitName As Integer
> Dim intLength As Integer
> intLength = Len(strDocName)
> intSplitName = InStrRev(strDocName, "\", , vbTextCompare)
> strDocName = Right(strDocName, intLength - intSplitName)
>
>
> objApp.Windows(strDocName).Activate
> objApp.ActiveWindow.Close SaveChanges:=wdDoNotSaveChanges
> So perhaps what the last line does is to shut the new document, since
> the original merge document is displayed. I have tried commenting out
> this code but that only results in an error. I will try changing
> ActiveWindow in the last line to strDocName!
>
> Many thanks for your time and trouble
>
> Murray
> murray.DeleteThis@geodesia.com-
>
>
> +-------------------------------------------------------------------+
> +-------------------------------------------------------------------+
>
>
>
> --
> Murray Muspratt-Rouse --
>
>
> +-------------------------------------------------------------------+
> +-------------------------------------------------------------------+
>
>
>
> --
> Murray Muspratt-Rouse -
(Msg. 14) Posted: Sat Aug 23, 2008 3:05 am
Post subject: Re: Word mailmerge - Visual Basic experts please help! [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
See Peter's previous message in which he says to use
Set objMMMD = objApp.Documents.Open (FileName: = strDocName, etc )
Probably all that you really need of that command is:
Set objMMMD = objApp.Documents.Open (FileName: = strDocName,
AddToRecentFiles:=False )
And that is on the assumption that you do not want the document to be added
to the list of most recently used files.
If that is not an issue, you can simply use
Set objMMMD = obj.App.Documents.Open(strDocName)
--
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
"Murray Muspratt-Rouse" <Murray.Muspratt-Rouse.2f49c30.DeleteThis@wordbanter.com> wrote
in message news:Murray.Muspratt-Rouse.2f49c30@wordbanter.com...
>
> I think I have overcome the Tools/References problem, but now I have
> another one: - I get an compile error message telling me that End of
> Statement was expected, highlighting FileName in the statement to which
> I have added 'Set objMMMD ='
>
> Set objMMMD = objApp.Documents.Open FileName:=strDocName,
> ConfirmConversions:=False, _
> ReadOnly:=False, AddToRecentFiles:=False _
> , PasswordDocument:="", _
> PasswordTemplate:="", Revert:=False, WritePasswordDocument:="",
> _
> WritePasswordTemplate:="", XMLTransform:=""
>
> Murray
>
> Peter Jamieson;359803 Wrote:
>> That is probably because the Word Object library has not been referenced
>> via
>> the Tools|References option in Access VBA. However, the original author
>> may
>> have avoided that deliberately because when you reference a library,
>> the
>> reference is to a specific version of Word.
>>
>> You can typically work around that using the following instead (you
>> just
>> don't see the autocomplete Help in the VBA editor that you would
>> otherwise
>> get)
>>
>> Dim objMMMD As Object
>>
>> --
>> Peter Jamieson
>> http://tips.pjmsn.me.uk >>
>> "Murray Muspratt-Rouse" Murray.Muspratt-Rouse.2f39f0e.DeleteThis@wordbanter.com
>> wrote
>> in message news:Murray.Muspratt-Rouse.2f39f0e@wordbanter.com...-
>>
>> Thank you Doug for referring me to Peter Jamieson's advice. I have
>> immediately run in to a problem - it does not like 'objMMMD As
>> Word.Document' telling me 'User-defined type not defined' and
>> suggesting that it might be in a properly registered object or type
>> library. Did I misunderstand Peter's advice? Was I meant to change
>> objMMMD to something else?
>>
>> Murray
>>
>> Doug Robbins - Word MVP;359552 Wrote:-
>> Actually, I did know what the code was doing, but did not understand
>> why.
>>
>> However, I suggest that you follow the advice given by Peter Jamieson
>> and
>> use
>>
>> Dim objMMMD As Word.Document
>> '
>> '
>> '
>> Set objMMMD = objApp.Documents.Open FileName:=strDocName, 'etc.
>> '
>> '
>> '
>> ' then when you want to close the mail merge main document, instead
>> of
>> having to
>> ' work out which window it is in, you can do
>>
>> objMMMD.Close SaveChanges:=False
>> '
>> ' then
>>
>> Set objMMMD = Nothing
>>
>>
>> --
>> 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
>>
>> "Murray Muspratt-Rouse" Murray.Muspratt-Rouse.2f24d94.DeleteThis@wordbanter.com
>> wrote
>> in message
>> news:Murray.Muspratt-Rouse.2f24d94@wordbanter.com...[color=blue][i]
>>
>> I agree with Doug about the code he does not understand - since I am
>> not
>> the original author of this code and do not speak VBA any way I have
>> been struggling to find my way to add new function to the
>> application.
>>
>> The merge document is selected by the user from an Access table in
>> which the full path to the file is stored, so what the code that we
>> cannot understand does is to strip off the path to the document from
>> strDocName: -
>> Dim intSplitName As Integer
>> Dim intLength As Integer
>> intLength = Len(strDocName)
>> intSplitName = InStrRev(strDocName, "\", , vbTextCompare)
>> strDocName = Right(strDocName, intLength - intSplitName)
>>
>>
>> objApp.Windows(strDocName).Activate
>> objApp.ActiveWindow.Close SaveChanges:=wdDoNotSaveChanges
>> So perhaps what the last line does is to shut the new document, since
>> the original merge document is displayed. I have tried commenting out
>> this code but that only results in an error. I will try changing
>> ActiveWindow in the last line to strDocName!
>>
>> Many thanks for your time and trouble
>>
>> Murray
>> murray.DeleteThis@geodesia.com-
>>
>>
>> +-------------------------------------------------------------------+
>> +-------------------------------------------------------------------+
>>
>>
>>
>> --
>> Murray Muspratt-Rouse -
>
>
> +-------------------------------------------------------------------+
> +-------------------------------------------------------------------+
>
>
>
> --
> Murray Muspratt-Rouse
(Msg. 15) Posted: Mon Aug 25, 2008 9:14 am
Post subject: Re: Word mailmerge - Visual Basic experts please help! [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
While thanking Peter and Doug for their advice I have to say that I have
a major problem - I am not sure what objMMMD is. Does it stand for Mail
Merge Main Document or something like that? If so is it meant to be
used to identify the document set up with merge fields, so as to make
it possible to close it without closing the result of the merge or
whatever? If I am right then I think I understand what I must do to use
it in the VBA code.
Also, because the References pop-up only shows me the first character
of the module name (C:\Program Files\Common Files\Microsoft
Office\OFFICE12\M) I do not whether one of the 12 dlls i can see is the
right one!
Murray
Doug Robbins - Word MVP;360024 Wrote:
> See Peter's previous message in which he says to use
>
> Set objMMMD = objApp.Documents.Open (FileName: = strDocName, etc )
>
> Probably all that you really need of that command is:
>
> Set objMMMD = objApp.Documents.Open (FileName: = strDocName,
> AddToRecentFiles:=False )
>
> And that is on the assumption that you do not want the document to be
> added
> to the list of most recently used files.
>
> If that is not an issue, you can simply use
>
> Set objMMMD = obj.App.Documents.Open(strDocName)
>
> --
> 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
>
> "Murray Muspratt-Rouse" Murray.Muspratt-Rouse.2f49c30.RemoveThis@wordbanter.com
> wrote
> in message
> news:Murray.Muspratt-Rouse.2f49c30@wordbanter.com...[color=blue][i]
>
> I think I have overcome the Tools/References problem, but now I have
> another one: - I get an compile error message telling me that End of
> Statement was expected, highlighting FileName in the statement to
> which
> I have added 'Set objMMMD ='
>
> Set objMMMD = objApp.Documents.Open FileName:=strDocName,
> ConfirmConversions:=False, _
> ReadOnly:=False, AddToRecentFiles:=False _
> , PasswordDocument:="", _
> PasswordTemplate:="", Revert:=False, WritePasswordDocument:="",
> _
> WritePasswordTemplate:="", XMLTransform:=""
>
> Murray
>
> Peter Jamieson;359803 Wrote:[color=green][i]
> That is probably because the Word Object library has not been
> referenced
> via
> the Tools|References option in Access VBA. However, the original
> author
> may
> have avoided that deliberately because when you reference a library,
> the
> reference is to a specific version of Word.
>
> You can typically work around that using the following instead (you
> just
> don't see the autocomplete Help in the VBA editor that you would
> otherwise
> get)
>
> Dim objMMMD As Object
>
> --
> Peter Jamieson
> http://tips.pjmsn.me.uk >
> "Murray Muspratt-Rouse" Murray.Muspratt-Rouse.2f39f0e.RemoveThis@wordbanter.com
> wrote
> in message news:Murray.Muspratt-Rouse.2f39f0e@wordbanter.com...-
>
> Thank you Doug for referring me to Peter Jamieson's advice. I have
> immediately run in to a problem - it does not like 'objMMMD As
> Word.Document' telling me 'User-defined type not defined' and
> suggesting that it might be in a properly registered object or type
> library. Did I misunderstand Peter's advice? Was I meant to change
> objMMMD to something else?
>
> Murray
(Msg. 16) Posted: Tue Aug 26, 2008 3:05 am
Post subject: Re: Word mailmerge - Visual Basic experts please help! [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
objMMMD is just a "label" assigned to a document object which by the command
Set objMMMD = objApp.Documents.Open (FileName: = strDocName, etc )
is being set to the document with the file name of strDocName, which I
believe is your mailmerge main document.
having done that, you can refer to that document by the label that is
assigned to the object.
There is nothing special about the MMMD other than it conveys some meaning
as you have deduced to the use of a person reading the code
You could just as well have used:
Dim doc as Object
Set doc = objApp.Documents.Open (FileName: = strDocName, etc )
but then doc does not convey as much intelligence to the user, other than it
probably refers to a document, but which one.
--
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
"Murray Muspratt-Rouse" <Murray.Muspratt-Rouse.2f82e3d DeleteThis @wordbanter.com> wrote
in message news:Murray.Muspratt-Rouse.2f82e3d@wordbanter.com...
>
> While thanking Peter and Doug for their advice I have to say that I have
> a major problem - I am not sure what objMMMD is. Does it stand for Mail
> Merge Main Document or something like that? If so is it meant to be
> used to identify the document set up with merge fields, so as to make
> it possible to close it without closing the result of the merge or
> whatever? If I am right then I think I understand what I must do to use
> it in the VBA code.
>
> Also, because the References pop-up only shows me the first character
> of the module name (C:\Program Files\Common Files\Microsoft
> Office\OFFICE12\M) I do not whether one of the 12 dlls i can see is the
> right one!
>
> Murray
>
> Doug Robbins - Word MVP;360024 Wrote:
>> See Peter's previous message in which he says to use
>>
>> Set objMMMD = objApp.Documents.Open (FileName: = strDocName, etc )
>>
>> Probably all that you really need of that command is:
>>
>> Set objMMMD = objApp.Documents.Open (FileName: = strDocName,
>> AddToRecentFiles:=False )
>>
>> And that is on the assumption that you do not want the document to be
>> added
>> to the list of most recently used files.
>>
>> If that is not an issue, you can simply use
>>
>> Set objMMMD = obj.App.Documents.Open(strDocName)
>>
>> --
>> 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
>>
>> "Murray Muspratt-Rouse" Murray.Muspratt-Rouse.2f49c30 DeleteThis @wordbanter.com
>> wrote
>> in message
>> news:Murray.Muspratt-Rouse.2f49c30@wordbanter.com...[color=blue][i]
>>
>> I think I have overcome the Tools/References problem, but now I have
>> another one: - I get an compile error message telling me that End of
>> Statement was expected, highlighting FileName in the statement to
>> which
>> I have added 'Set objMMMD ='
>>
>> Set objMMMD = objApp.Documents.Open FileName:=strDocName,
>> ConfirmConversions:=False, _
>> ReadOnly:=False, AddToRecentFiles:=False _
>> , PasswordDocument:="", _
>> PasswordTemplate:="", Revert:=False, WritePasswordDocument:="",
>> _
>> WritePasswordTemplate:="", XMLTransform:=""
>>
>> Murray
>>
>> Peter Jamieson;359803 Wrote:[color=green][i]
>> That is probably because the Word Object library has not been
>> referenced
>> via
>> the Tools|References option in Access VBA. However, the original
>> author
>> may
>> have avoided that deliberately because when you reference a library,
>> the
>> reference is to a specific version of Word.
>>
>> You can typically work around that using the following instead (you
>> just
>> don't see the autocomplete Help in the VBA editor that you would
>> otherwise
>> get)
>>
>> Dim objMMMD As Object
>>
>> --
>> Peter Jamieson
>> http://tips.pjmsn.me.uk >>
>> "Murray Muspratt-Rouse" Murray.Muspratt-Rouse.2f39f0e DeleteThis @wordbanter.com
>> wrote
>> in message news:Murray.Muspratt-Rouse.2f39f0e@wordbanter.com...-
>>
>> Thank you Doug for referring me to Peter Jamieson's advice. I have
>> immediately run in to a problem - it does not like 'objMMMD As
>> Word.Document' telling me 'User-defined type not defined' and
>> suggesting that it might be in a properly registered object or type
>> library. Did I misunderstand Peter's advice? Was I meant to change
>> objMMMD to something else?
>>
>> Murray
>
>
> +-------------------------------------------------------------------+
> +-------------------------------------------------------------------+
>
>
>
> --
> Murray Muspratt-Rouse
All times are: Eastern Time (US & Canada) (change) Goto page Previous1, 2, 3, 4
Page 2 of 4
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum