Thread: Macro errors
View Single Post
 
Old 09-17-2012, 06:11 AM
muster36 muster36 is offline Windows 7 64bit Office 2010 32bit
Novice
 
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