Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-12-2012, 10:06 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 Macro errors

1. When first compiled and then run a macro called, say, "HDD" runs OK. Next time I try to run it I get message that file C:windows\system32\HDD.docx cannot be found - but the path is E:\DOCUMENTS\HDD.docx and this shows as the path when I "step into" the macro.
Other Macros with the same path to E:\DOCUMENTS\*.docx run without problem. and looking at the Macro instructions for all these macros the "instructions" appear identical with only the actual name of the file being different

2.Another problem which is occuring frequently is when I run eg macro to open file E:\DOCUMENTS\ABC.docx and then close the Document if I next try to run Macro to open file E:\DOCUMENTS\xyz.docx I get the message "file E:\DOCUMENTS\ABC\xyz.docx cannot be found - which of course it cannot find -as the path to "xyz" is not via file "ABC"!
Very confused



Can anyone help,please?
Reply With Quote
  #2  
Old 09-12-2012, 06:24 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

Quote:
Can anyone help,please?
Not without seeing the code.

PS: When posting code, please use the code tags. They're on the 'Go Advanced' tab.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 09-13-2012, 08:40 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

Thanks for replying
Cannot find GO ADVANCED tab and so I cannot find the Code tags!! Help please!
Could I send you the VB instruction for the macros in question from the View/macros/Step into Window. Would this help?
Reply With Quote
  #4  
Old 09-13-2012, 03:21 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

The 'Go Advanced' tab is immediately below the box you type your posts into ...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 09-14-2012, 03:14 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

Code:
'DavidCoupe Macro
'
'
ChangeFileOpenDirectory "E:\DOCUMENTS\COUPE\"
Documents.Open FileName:="D_C.dotm", ConfirmConversions:=False, ReadOnly:= _
    False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _
    "", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _
    Format:=wdOpenFormatAuto, XMLTransform:=""
Selection.MoveDown Unit:=wdLine, Count:=6
End Sub
 
Sub HDDJtPaper()
'
' HDDJtPaper Macro
'
' ChangeFileOpenDirectory "E:\DOCUMENTS\"
Documents.Open FileName:="HDDjt.docx", ConfirmConversions:=False, ReadOnly _
    :=False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate _
    :="", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="" _
    , Format:=wdOpenFormatAuto, XMLTransform:=""
Selection.MoveDown Unit:=wdLine, Count:=8
End Sub
 
Sub QUESTA()
'
' QUESTA Macro
'
'
ChangeFileOpenDirectory "E:\DOCUMENTS\QUESTA\"
Documents.Open FileName:="CHRIS.doc", ConfirmConversions:=False, ReadOnly _
    :=False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate _
    :="", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="" _
    , Format:=wdOpenFormatAuto, XMLTransform:=""
Selection.MoveDown Unit:=wdLine, Count:=7
End Sub
 
Sub HDDR()
'
' HDDR Macro
'
'
ChangeFileOpenDirectory "E:\DOCUMENTS\"
Documents.Open FileName:="HDDRpaper.docx", ConfirmConversions:=False, _
    ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
    PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
    WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""
End Sub
Thanks. It is so easy when you know where to look!!! Have sent details.

Last edited by macropod; 09-14-2012 at 04:15 AM. Reason: Added code tags & formatting
Reply With Quote
  #6  
Old 09-14-2012, 03:42 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

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
  #7  
Old 09-14-2012, 04:09 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

Hi
Not conversant with VB and so need further clarifcation
These are three separate Macros
When I copy the details you sent to create one of the macros should it appear as I have done it and repeat for each separate macro with each starting Call OpenDoc followed by path etc
Code:
Sub DCOUPE22()
'
' DCOUPE22 Macro
'
'Call OpenDoc("E:\DOCUMENTS\COUPE\D_C.dotm")
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
When I try to run this I get message after first EndSub
Compile error
Ambiguous name detected: Open Doc

Can you help further please

Last edited by macropod; 09-14-2012 at 04:13 AM. Reason: Added code tags & formatting
Reply With Quote
  #8  
Old 09-14-2012, 04:11 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 macros I posted would replace the macros you posted.

PS: You're still not using the code tags.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 09-14-2012, 04:24 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

Sorry - What ARE Code tags? !!!!
Reply With Quote
  #10  
Old 09-14-2012, 04:29 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

After pressing the 'Go Advanced' tab, a new window opens. There you'll see a button with # on it. That inserts the code tags. Your code goes between them. The add '['code']' to the start of your code and '['/code']' after it (without the single quotes).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 09-14-2012, 04:34 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
Red face

Sorry for being so ignorant about all this but what Are the codes I have to insert
Reply With Quote
  #12  
Old 09-14-2012, 04:37 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

When you post macro code, that is what needs to have the code tags at each end; otherwise whatever structure your code has is lost - and that makes it harder to understand.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #13  
Old 09-14-2012, 04:40 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

Please give me an example of code tag as I still do not understand what to put down
Reply With Quote
  #14  
Old 09-14-2012, 04:14 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

Quote:
Originally Posted by muster36 View Post
Please give me an example of code tag as I still do not understand what to put down
Are you even paying attention to anything I posted on this matter? Have you looked at the Advanced screen? It's not rocket science ...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #15  
Old 09-15-2012, 03:09 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

Thanks for the comment! I am trying - but obviously "very trying" to you!!! I hope I have posted the code tags correctly?!!
Have copied and pasted the instructions you gave and applied them to the macro for DavidCoupe.
When I run it I get the message Compile error:Ambiguous name detected:OpenDoc
As my Macros were all created using the Word links- View\Macros\RecordMacro I would have expected the codes created to run without changing. Not all PC users have the skills ( as my posts confirm!) to change the coding

Code:
Call OpenDoc("E:\DOCUMENTS\COUPE\D_C.dotm")
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
Thanks again for your patience and I hope it has not run out.................!

Last edited by macropod; 09-15-2012 at 03:16 AM. Reason: code re-structure
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:02 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