Open saved OLE document

sharky12345

Well-known Member
Joined
Aug 5, 2010
Messages
3,421
Office Version
  1. 2016
Platform
  1. 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?
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
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!
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top