#16
|
||||
|
||||
The 'Compile error:Ambiguous name detected:OpenDoc' suggests you have more than one Sub OpenDoc in the module. Did you have another Sub OpenDoc in the same module before?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#17
|
|||
|
|||
Thank you for your reply
This is the full code copied as per your original answer and yes there are two OpenDoc entries Code:
' MMM Macro ' 'Call OpenDoc("E:\DOCUMENTS\MMM\LETTER.doc") Selection.MoveDown Unit:=wdLine, Count:=6 End Sub Sub OpenDoc(StrDoc As String) Documents.Open FileName:="StrDoc", ConfirmConversions:=False, ReadOnly:= _ False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _ "", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _ Format:=wdOpenFormatAuto, XMLTransform:="" End Sub |
#18
|
||||
|
||||
As you will see from the code I posted, there can be multiple 'Call OpenDoc' entries - each of subs except the last has one. That is not the problem. However, a code module can only have one sub named Sub OpenDoc. What concerns me about the code snippet you posted, though, is that the first code block doesn't have a sub name; it should have a first line like Sub MMM(). If that is lacking, you can run that sub and it may cause the errors you're experiencing.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#19
|
|||
|
|||
Full macro below. Even with Sub MMM() inserted get
code line, highlighted in red below, highlighted with the message Compile error Ambiguous name detected:OpenDoc Code:
Sub MMM() ' ' MMM Macro ' 'Call OpenDoc("E:\DOCUMENTS\MMM\LETTER.doC") Selection.MoveDown Unit:=wdLine, Count:=6 End Sub Sub OpenDoc(StrDoc As String) Documents.Open FileName:="StrDoc", ConfirmConversions:=False, ReadOnly:= _ False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _ "", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _ Format:=wdOpenFormatAuto, XMLTransform:="" End Sub |
#20
|
||||
|
||||
Getting "Ambiguous name detected:OpenDoc" indicates that you have more than one sub named OpenDoc. As I said in my last post:
Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#21
|
|||
|
|||
This is the code you first sent to me in response to my initial query
[code] Sub DavidCoupe() 'DavidCoupe Macro ' Call OpenDoc("E:\DOCUMENTS\COUPE\D_C.dotm") Selection.MoveDown Unit:=wdLine, Count:=6 End Sub Sub HDDJtPaper() ' HDDJtPaper Macro Call OpenDoc("E:\DOCUMENTS\HDDjt.docx") Selection.MoveDown Unit:=wdLine, Count:=8 End Sub Sub QUESTA() ' QUESTA Macro ' Call OpenDoc("E:\DOCUMENTS\QUESTA\CHRIS.doc") Selection.MoveDown Unit:=wdLine, Count:=7 End Sub Sub HDDR() ' HDDR Macro ' Call OpenDoc("E:\DOCUMENTS\HDDRpaper.docx") End Sub Sub OpenDoc(StrDoc As String) Documents.Open FileName:="StrDoc", ConfirmConversions:=False, ReadOnly:= _ False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _ "", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _ Format:=wdOpenFormatAuto, XMLTransform:="" Applying the same principle to the code for Macro MMM it reads as below (with 2 OpenDoc references) Code:
Sub MMM() ' ' MMM Macro ' 'Call OpenDoc("E:\DOCUMENTS\MMM\LETTER.doC") Selection.MoveDown Unit:=wdLine, Count:=6 End Sub Sub OpenDoc(StrDoc As String) Documents.Open FileName:="StrDoc", ConfirmConversions:=False, ReadOnly:= _ False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _ "", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _ Format:=wdOpenFormatAuto, XMLTransform:="" BUT If I try to run the macro with only one OpenDoc instruction Code:
Sub MMM() ' ' MMM Macro ' 'Call OpenDoc("E:\DOCUMENTS\MMM\LETTER.doC") Selection.MoveDown Unit:=wdLine, Count:=6 End Sub What am I doing wrong,please? Last edited by muster36; 09-17-2012 at 06:13 AM. Reason: Typo error |
#22
|
||||
|
||||
How many times do I have to say you can have only one 'Sub OpenDoc' in a module?
You can have as many 'Call OpenDoc' commands as you like (within their own subs), but you can have only one 'Sub OpenDoc'!!!!!
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#23
|
|||
|
|||
Okay!
You can see from my previous post that this Macro HAS only ONE Sub OpenDoc and it STILL gives the message Compile Error :Ambiguous name detected:OpenDoc Code:
Sub MMM() ' ' MMM Macro ' 'Call OpenDoc("E:\DOCUMENTS\MMM\LETTER.doC") Selection.MoveDown Unit:=wdLine, Count:=6 End Sub Sub OpenDoc(StrDoc As String) Documents.Open FileName:="StrDoc", ConfirmConversions:=False, ReadOnly:= _ False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _ "", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _ Format:=wdOpenFormatAuto, XMLTransform:="" |
#24
|
||||
|
||||
I cannot see from your post that you have only one Sub OpenDoc in the whole code module - all I can see is what you've posted. The simple fact is that the error message only occurs because you have more than one such sub.
Perhaps you would care to attach the affected document to a post with some representative data (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab. Please also make sure your code is properly formatted when you post it, by previewing the post.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#25
|
|||
|
|||
This is the entire Code for this Macro (as per the code you sent originally for the other macros)
I have attached the file which it is meant to open and which is a letter heading with the recipient's address entered and the Macro finishing where the date is to be inserted Code:
Sub MMM() ' ' MMM Macro ' 'Call OpenDoc("E:\DOCUMENTS\MMM\LETTER.doc") Selection.MoveDown Unit:=wdLine, Count:=6 End Sub Sub OpenDoc(StrDoc As String) Documents.Open FileName:="StrDoc", ConfirmConversions:=False, ReadOnly:= _ False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _ "", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _ Format:=wdOpenFormatAuto, XMLTransform:="" |
#26
|
||||
|
||||
There are no macros of any kind in your attachment.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#27
|
|||
|
|||
Hope the code gets to you this time
Code:
Sub MMM() ' ' MMM Macro ' 'Call OpenDoc("E:\DOCUMENTS\MMM\LETTER.doc") Selection.MoveDown Unit:=wdLine, Count:=6 End Sub Sub OpenDoc(StrDoc As String) Documents.Open FileName:="StrDoc", ConfirmConversions:=False, ReadOnly:= _ False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _ "", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _ Format:=wdOpenFormatAuto, XMLTransform:="" |
#28
|
||||
|
||||
There is no attachment to your last post - and you haven't formatted the code properly...
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#29
|
|||
|
|||
I have uploaded the file per the Paper clip icon as instructed
I have put the code for the macro between the Instructed code brackets as below Code:
Sub MMM() ' ' MMM Macro ' 'Call OpenDoc("E:\DOCUMENTS\MMM\LETTER.doc") Selection.MoveDown Unit:=wdLine, Count:=6 End SubSub OpenDoc(StrDoc As String) Documents.Open FileName:="StrDoc", ConfirmConversions:=False, ReadOnly:= _ False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _ "", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _ Format:=wdOpenFormatAuto, XMLTransform:="" If I, as a doctor, told you to remove someones appendix you might need a lot of guidance so I, as a PC user, with no knowledge of computer coding also needs a lot of guidance I am very grateful for your continuing patience |
#30
|
||||
|
||||
OK, but if you as a parent had a sick child child and I asked you to bring her to my surgery so that I could perform a diagnosis, would you bring just a picture? There are no macros in your attached document. Repeatedly putting just some of your code into your posts instead is a waste of time.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Errors in Outlook.pst | Rik_StHelens | Outlook | 0 | 12-20-2010 09:40 AM |
Strange errors | omirza | Excel | 0 | 02-05-2010 01:30 PM |
Encryption XOR - any errors??? | Word Doc | Word | 1 | 10-08-2009 12:57 AM |
COM Automation Errors | ivanm | Word | 0 | 03-23-2009 07:02 PM |
How do you fix ost in use errors? | enviroko | Outlook | 0 | 10-23-2008 09:49 AM |