Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 09-15-2012, 03:18 AM
macropod's Avatar
macropod macropod is online now Macro errors Windows 7 64bit Macro errors Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default


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]
Reply With Quote
  #17  
Old 09-15-2012, 03:23 PM
muster36 muster36 is offline Macro errors Windows 7 64bit Macro errors Office 2010 32bit
Novice
Macro errors
 
Join Date: Aug 2011
Posts: 23
muster36 is on a distinguished road
Default

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
Reply With Quote
  #18  
Old 09-15-2012, 08:40 PM
macropod's Avatar
macropod macropod is online now Macro errors Windows 7 64bit Macro errors Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #19  
Old 09-16-2012, 05:39 AM
muster36 muster36 is offline Macro errors Windows 7 64bit Macro errors Office 2010 32bit
Novice
Macro errors
 
Join Date: Aug 2011
Posts: 23
muster36 is on a distinguished road
Default

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
Reply With Quote
  #20  
Old 09-16-2012, 08:07 AM
macropod's Avatar
macropod macropod is online now Macro errors Windows 7 64bit Macro errors Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Getting "Ambiguous name detected:OpenDoc" indicates that you have more than one sub named OpenDoc. As I said in my last post:
Quote:
a code module can only have one sub named Sub OpenDoc.
How many subs named OpenDoc do you have?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #21  
Old 09-17-2012, 06:11 AM
muster36 muster36 is offline Macro errors Windows 7 64bit Macro errors Office 2010 32bit
Novice
Macro errors
 
Join Date: Aug 2011
Posts: 23
muster36 is on a distinguished road
Default

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:=""
I get the error code which you say is due to two OpenDoc instructions

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
Nothing happens ie the macro does not run

What am I doing wrong,please?

Last edited by muster36; 09-17-2012 at 06:13 AM. Reason: Typo error
Reply With Quote
  #22  
Old 09-17-2012, 06:27 AM
macropod's Avatar
macropod macropod is online now Macro errors Windows 7 64bit Macro errors Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #23  
Old 09-17-2012, 07:02 AM
muster36 muster36 is offline Macro errors Windows 7 64bit Macro errors Office 2010 32bit
Novice
Macro errors
 
Join Date: Aug 2011
Posts: 23
muster36 is on a distinguished road
Default

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:=""
Reply With Quote
  #24  
Old 09-17-2012, 07:56 PM
macropod's Avatar
macropod macropod is online now Macro errors Windows 7 64bit Macro errors Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #25  
Old 09-18-2012, 02:59 AM
muster36 muster36 is offline Macro errors Windows 7 64bit Macro errors Office 2010 32bit
Novice
Macro errors
 
Join Date: Aug 2011
Posts: 23
muster36 is on a distinguished road
Default

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:=""
Attached Files
File Type: doc LETTER.doc (23.0 KB, 7 views)
Reply With Quote
  #26  
Old 09-18-2012, 03:33 AM
macropod's Avatar
macropod macropod is online now Macro errors Windows 7 64bit Macro errors Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

There are no macros of any kind in your attachment.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #27  
Old 09-18-2012, 07:41 AM
muster36 muster36 is offline Macro errors Windows 7 64bit Macro errors Office 2010 32bit
Novice
Macro errors
 
Join Date: Aug 2011
Posts: 23
muster36 is on a distinguished road
Default

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:=""
Reply With Quote
  #28  
Old 09-18-2012, 03:00 PM
macropod's Avatar
macropod macropod is online now Macro errors Windows 7 64bit Macro errors Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

There is no attachment to your last post - and you haven't formatted the code properly...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #29  
Old 09-20-2012, 04:12 AM
muster36 muster36 is offline Macro errors Windows 7 64bit Macro errors Office 2010 32bit
Novice
Macro errors
 
Join Date: Aug 2011
Posts: 23
muster36 is on a distinguished road
Default

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:=""
I do not know how to format code and can only send what I have copied from your initial Reply.

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
Attached Files
File Type: doc LETTER.doc (23.0 KB, 7 views)
Reply With Quote
  #30  
Old 09-20-2012, 03:44 PM
macropod's Avatar
macropod macropod is online now Macro errors Windows 7 64bit Macro errors Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply

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
Macro errors 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

Other Forums: Access Forums

All times are GMT -7. The time now is 06:10 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft