Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro works, then doesn't 1

Status
Not open for further replies.

somedea

MIS
Jul 13, 2004
162
US
We have recorded several macros to use for a new letterhead here in the office. We recorded them to document 1 and then saved them as .dot files in Office\Startup. They basically insert a document into the existing document to set up formatting and insert a logo. We saved local copies of the document they insert to the Office\Startup folder as well (as .doc's).
The problem is that they run fine for a while, then they fail with a 5174 "file cannot be found" error. The file they refer to is the .doc file. Closing and reopening Word doesn't fix the problem, but rebooting does.
Any ideas? Could it be the location of the saved docs?
Here is the code for one of them:
Sub LetterheadelecwithDD()
'
' LetterheadelecwithDD Macro
' Macro recorded 11/14/2007 by Dana Dea
'
ChangeFileOpenDirectory _
"C:\Program Files\Microsoft Office\Office\Startup\"
Selection.InsertFile FileName:="LetterheadelecWITHDD.doc", Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
Selection.Font.Name = "TradeGothic LT"
End Sub

 





Try this...
Code:
Sub LetterheadelecwithDD()
'
' LetterheadelecwithDD Macro
' Macro recorded 11/14/2007 by Dana Dea
'
    Selection.InsertFile FileName:="C:\Program Files\Microsoft Office\Office\Startup\LetterheadelecWITHDD.doc", Range:="", _
        ConfirmConversions:=False, Link:=False, Attachment:=False
    Selection.Font.Name = "TradeGothic LT"
End Sub


Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
Thanks for the help, Skip. I removed those two lines and it ran once, then went back to the same behavior as before.???
 
So sorry, I made an error in the new file path. I'm testing on all the macros and it looks good! We'll test to be sure they don't start to break again.
Thanks so much for the quick help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top