please bear with me and read through the scenario.
I have a .docm file that lives in a SharePoint document library. When it is opened, a macro fires that prompts the user for a new file name and folder and then uses .SaveAs2 to save a copy of the file in the specified location as a .docx without the macro.
I cannot use content types with a proper .dotm, since there are over 30 different file templates in the library. I haveto use the .docm in a SharePoint library and then make sure that the user saves a copy of the file to their personal drive.
So I use some code in the open event. I let the user specify a folder and a file name. Then .SaveAs2 takes these parameters and saves the current file in the new path with the new name as a normal .docx file without macros. I 'll spare you the details about how strFolder and strDoc are gathered. Rest assured that they exist. I have a debug.print with the full file name and it is correct.
.SaveAs2 strFolder & strDoc & ".docx", wdFormatDocumentDefault
The problem is that this code brings up a message saying that the file cannot be found.
Well, duh, I am trying to save the file in this location. Of course it does not exist. That's the point (let me assure you that the folder DOES exist).
Now the fun bit. After the message box is closed, Word happily saves the file to the specified location.
Another fun bit: The message only pops up if the original file is opened in Read mode from SharePoint AND if the new file path is on a network drive.
The message does NOT
pop up if
- the file is opened in Edit mode (click the SharePoint file, select Edit in the next dialog), or if
- the file is saved to a local drive (C:\) or if
- the file is opened from the File > Recent backstage dialog.
In the production system, the users will not have a choice of Edit or Read only. They will default to Read only. Also the users will not be able to save to a local C:\ drive, since the business system puts their profile and "My Documents" on a network drive (H:\).
I have tried
- saving the file with a different approach: using msoFileDialogSaveAs -- same message
- suppressing the message with Application.DisplayAlert = False. - Does not work. Message still shows
- suppressing the message with Application.ScreenUpdating
= False. Does not work. The message still shows.
Why does Read or Edit mode matter when the file is saved to a new location?
Why does the new location of the file (network path or local path) matter when it is saved?
And anyway, why does the message come up when afterwards the file saves correctly?
I don't need answers to these three why questions, I just want the message to go away.
Please try to repro the scenario before posting. Any suggestions?