Open saved OLE document

sharky12345

Well-known Member
Joined
Aug 5, 2010
Messages
3,303
Office Version
2016
Platform
Windows
I'm using this to save an OLE Word document as a pdf;

Code:
Dim appWord As Object
If ActiveWorkbook Is Nothing Then Exit Sub
Application.ScreenUpdating = False
DestFolder = ThisWorkbook.Path & "\Toolbox Files"
Set wsActive = ActiveSheet
lCnt = 0
Sheets("Setup").Activate
Set ws = Sheets("Setup")
ActiveSheet.OLEObjects("Object 2").Select
ActiveSheet.OLEObjects("Object 2").Verb xlVerbPrimary
Set oDoc = ActiveSheet.OLEObjects("Object 2").Object
If appWord Is Nothing Then
Set appWord = oDoc.Parent
End If
oDoc.Bookmarks("IN").Range.InsertAfter H2Frm.ComboI.Value
oDoc.Bookmarks("DA").Range.InsertAfter H2Frm.TextDate.Value & " " & H2Frm.TextTime.Value & " hrs"
oDoc.Bookmarks("RM").Range.InsertAfter H2Frm.TextRM.Value
strFile = "H2 - RM number " & H2Frm.TextRM.Value & ".pdf"
oDoc.SaveAs ThisWorkbook.Path & "\Toolbox Files\" & strFile, FileFormat:=17
oDoc.Close savechanges:=False
lCnt = lCnt + 1
If Not appWord Is Nothing Then
appWord.Quit
End If
Application.ScreenUpdating = True
ActiveWindow.WindowState = xlMaximized
What I need to do though is open it after saving - can anyone show me how please?
 

Some videos you may like

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,170
Instead of using the SaveAs method of the Document object, try using the ExportAsFixedFormat method of the Document object, and set the OpenAfterExport argument to True.

Hope this helps!
 

Watch MrExcel Video

Forum statistics

Threads
1,099,535
Messages
5,469,260
Members
406,645
Latest member
jasondabsher

This Week's Hot Topics

Top