#1
|
|||
|
|||
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? |
#2
|
||||
|
||||
Quote:
PS: When posting code, please use the code tags. They're on the 'Go Advanced' tab.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
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? |
#4
|
||||
|
||||
The 'Go Advanced' tab is immediately below the box you type your posts into ...
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
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 Last edited by macropod; 09-14-2012 at 04:15 AM. Reason: Added code tags & formatting |
#6
|
||||
|
||||
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
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
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 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 |
#8
|
||||
|
||||
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] |
#9
|
|||
|
|||
Sorry - What ARE Code tags? !!!!
|
#10
|
||||
|
||||
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] |
#11
|
|||
|
|||
Sorry for being so ignorant about all this but what Are the codes I have to insert
|
#12
|
||||
|
||||
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] |
#13
|
|||
|
|||
Please give me an example of code tag as I still do not understand what to put down
|
#14
|
||||
|
||||
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] |
#15
|
|||
|
|||
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 Last edited by macropod; 09-15-2012 at 03:16 AM. Reason: code re-structure |
|
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 |