View Single Post
  #17   Report Post  
Murray Muspratt-Rouse Murray Muspratt-Rouse is offline
Member
 
Location: Mill Hill, London, England
Posts: 44
Default

I tried 'Dim objMMMD As Word.Document' again and got the error message "User-defined type not defined'. This is what makes me think I do not have the correct objMMMD module registered. I tried 'Dim objMMMD As Object' and the result was that the Mail Merge document was closed, but the display of the merge result only showed one document, instead of the 3 that I expected.

Murray

[quote=Murray Muspratt-Rouse;360272]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

Quote:
Originally Posted by Doug Robbins - Word MVP View Post
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" wrote
in message ...[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"
wrote
in message ...-

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