I have a macro that works fine in the shared drive when it is only accessed by one/first person. When it is accessed by the second person while the first person still has it open, it says it's already open. When I click "create a local copy and merge changes later" the macro will work up until it saves the file.
The macro basically invokes a userform to collect information, fill in the document, and then it should save the document as a PDF to the desktop. The PDF isn't saving in the local copy version for some reason. When the "Follow hyperlink" comes up, it says "Error 4198, command failed". I check my desktop and the file isn't there, leading me to believe that this error is in relation to the file not being created....
I just need the macro to allow the document to be saved to their desktop as a pdf, whether they're in the normal version, or the local copy created as a byproduct of the shared drive rules.
Main_Form.hide
enviro = CStr(Environ("USERPROFILE"))
sName = Format(Date, "mm-dd-yyyy") & " Denial Letter - Invoice " & Invoice_Text.Value & ".pdf"
sPath = enviro & "\Desktop\"
ThisDocument.SaveAs2 FileName:=sPath & sName, fileformat:=wdFormatPDF
fullName = sPath & sName
ThisDocument.FollowHyperlink fullName
ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
Use a template (dotm), not a document. Create new documents from the template, that way there will be no document "lock".
Also, don't use ThisDocument
as that means specifically the document in which the VBA code is located, use ActiveDocument
, instead.