Thread: Macro errors
View Single Post
 
Old 09-14-2012, 03:42 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

Your 'HDDJtPaper' macro is liable to fail after running, say, 'QUESTA' as that macro changes the working folder to its own. Essentially, the problem is the unnecessary changing of folders. Try:
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:=""
End Sub
Note how I've simplified everything and how, instead of changing folders, the new code simply tells Word which folder to open the file from.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote