Tr3yAnderson
New Member
- Joined
- Aug 31, 2015
- Messages
- 16
Hey guys, I have a macro where it saves a word file; however, it won't always run, everyone once in awhile it throws the error 462: The remote server machine does not exist. or it'll throw an error saying can't find active document. it will work through once I go to the task manager and close out any orphaned Word processes. Does anyone know what I can add to my code to not have any orphaned Word processes, or if there are some, to clear them out? I thought by closing out my macro by setting wordapp to nothing and quitting Word would do it but it does not fix it.
Thanks,
Sub Save_Narrative() 'This Saves the Narrative as a word file and as a PDF in a designated folder
Dim wordApp As Word.Application
Dim wordDoc As Word.document
Dim DocName As String
Dim NewdocName As String
Set wordApp = Nothing
Set wordApp = CreateObject("Word.Application")
Set wordDoc = ActiveDocument
DocName = wordDoc.Name
'Save as word file
wordDoc.SaveAs FileName:=([redacted])
'remove .docx from file name
NewdocName = Left(DocName, Len(DocName) - 5) & ".pdf"
'save as PDF
wordDoc.SaveAs FileName:=([redacted]), FileFormat:=17
wordDoc.Close SaveChanges:=False
Set wordDoc = Nothing
wordApp.Quit
Set wordApp = Nothing
End Sub
Thanks,
Sub Save_Narrative() 'This Saves the Narrative as a word file and as a PDF in a designated folder
Dim wordApp As Word.Application
Dim wordDoc As Word.document
Dim DocName As String
Dim NewdocName As String
Set wordApp = Nothing
Set wordApp = CreateObject("Word.Application")
Set wordDoc = ActiveDocument
DocName = wordDoc.Name
'Save as word file
wordDoc.SaveAs FileName:=([redacted])
'remove .docx from file name
NewdocName = Left(DocName, Len(DocName) - 5) & ".pdf"
'save as PDF
wordDoc.SaveAs FileName:=([redacted]), FileFormat:=17
wordDoc.Close SaveChanges:=False
Set wordDoc = Nothing
wordApp.Quit
Set wordApp = Nothing
End Sub