oldSarge98
Programmer
Working in Excel 2010 with an embedded Word Document. I want to export(save) the Word Document Object as a .docx file in the file system folder. The following code does the job but when the object is activated it briefly flashes on the screen. I want to avoid that. Here's a sample of the code I've developed:
Any recommendations?
Code:
Sub SaveEmbeddedFile()
Dim xlsWst As Worksheet
Dim strArchivePath As String
Dim objOle As OLEObject
Dim appWord As Word.Application
Dim wrdDoc As Word.Document
strArchivePath = Me.Path & "\attachments"
Set xlsWst = ThisWorkbook.Worksheets("attachments")
Set objOle = xlsWst.OLEObjects("HelpDocument")
objOle.Visible = False [highlight #FCE94F]' does not prevent the flash[/highlight]
[highlight #FCE94F] ' this is where the word OLE object flashes on the screen[/highlight]
objOle.Activate
Set wrdDoc = objOle.Object
wrdDoc.Application.Visible = False
wrdDoc.SaveAs2 Filename:=strArchivePath & "\help.docx"
wrdDoc.Close
Set wrdDoc = Nothing
[highlight #FCE94F] ' if the following two lines are omitted we are left with
' an instance of WINWORD.EXE in the system processes
' but, I'm concerned that doing this will interfere with any
' Word instances that the user might have had opened before
' having this module executed
[/highlight] Set appWord = GetObject(Class:="Word.Application")
appWord.Quit
Set appWord = Nothing
End Sub 'SaveEmbeddedFile
Any recommendations?