![]() |
|
|
|
#1
|
||||
|
||||
|
I have no trouble running the code like:
Code:
Private Sub Savetemplate1_Click()
Dim myotherfilename As String, myfilename As String
ChangeFileOpenDirectory "M:\Care Plan System\"
myotherfilename = Options.DefaultFilePath(wdDocumentsPath)
myfilename = InputBox("Enter file name for document " & myfilename)
myfilename = myotherfilename + "\Care Plan System\" + myfilename
ActiveDocument.SaveAs FileName:=myfilename, FileFormat:=wdFormatXMLTemplateMacroEnabled
Application.DisplayAlerts = False
ActiveDocument.SaveAs FileName:=myfilename, FileFormat:=wdFormatXMLDocument
Application.DisplayAlerts = True
End Sub
Something I have noticed, though, is that you're using ChangeFileOpenDirectory before storing wdDocumentsPath. That means the wdDocumentsPath = "M:\Care Plan System\". Perhaps you need to reverse the order of these statements, because what you're getting now is, in effect: myfilename = "M:\Care Plan System\Care Plan System\" + myfilename It seems strange that you'd have a subfolder with the same name as its parent. Also, having stored wdDocumentsPath in myotherfilename, you don't ever restore it: Options.DefaultFilePath(wdDocumentsPath) = myotherfilename Of course, that would be futile at the moment, because of the order in which you're using ChangeFileOpenDirectory and storing wdDocumentsPath.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#2
|
|||
|
|||
|
Hello Paul
You are being so helpful and yet I still cannot get mine to work. I have gone back to basics and created a macro by recording the steps I am taking. Here is the very simple bit of code, no filenames being input or anything, and yet it still fails for me. Code:
Private Sub CommandButton1_Click()
ActiveDocument.SaveAs FileName:="M:\Care Plan System\testdoc 1259.docx", _
FileFormat:=wdFormatXMLDocument, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False
End Sub
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Microsoft office 2010 error 2908 and error 1935 !!!!!!heeeeellpppp!!!!!!!!!
|
bennypryde | Office | 1 | 01-05-2012 03:33 PM |
saveAs ChDir _
|
tinfanide | Excel Programming | 4 | 11-05-2011 01:40 AM |
| Handling Excel Data | msofficeno475 | Excel | 1 | 01-17-2010 09:56 AM |
| Runtime error 5487 - Word cannot complete the save to to file permission error | franferns | Word | 0 | 11-25-2009 05:35 AM |
| Handling ICALENDAR attachments | l_kris06 | Outlook | 0 | 11-12-2008 07:22 AM |