Document opens when embedding

Hafi

New Member
Joined
Jan 26, 2023
Messages
2
Office Version
  1. 2021
Platform
  1. Windows
Hi,

I am trying to embed multiply files (with different file extensions) in a folder using a loop. Adding the files works great, the problem is that when adding the files I get a pop-up for every single file asking "Do you want to open this file?" How do I prevent this from happening? I don't want the pop-up and I don't want the file to open.

I have tried to set application.enableevents and application.displayalerts to false but that doesn't help.


VBA Code:
Dim obj As OLEObject

Set obj = wsOutput.OLEObjects.Add(Filename:=strPathAndFilename, link:=False, displayasicon:=True)

with obj
  .height = 100
  .width=100
end with
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hi you can try turn off the alerts, don´t forget to turn them on after finishing.

VBA Code:
'Turn off alerts before running your code'
Application.DisplayAlerts = False

Dim obj As OLEObject

Set obj = wsOutput.OLEObjects.Add(Filename:=strPathAndFilename, link:=False, displayasicon:=True)
with obj
  .height = 100
  .width=100
end with
'Turn it back on after running your code'
Application.DisplayAlerts = True
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,183
Members
452,615
Latest member
bogeys2birdies

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