OleObject - File path for upload document

Abhishek1988

New Member
Joined
Oct 22, 2018
Messages
27
Hi Everyone,

I have one code which will browse document from provide path:

Code:

Sub Button1_Click()
Worksheets("Sheet1").OLEObjects.Add Filename:="XXX", Link:=False, DisplayAsIcon:=False, Left:=40, Top:=40, Width:=150, Height:=10
End Sub

My expectation:

1. Filename should be based on the case value. Example if i put complete path in A1 in same sheet then it should pickup from there.

2. Above code is extracting file in big format however i need the same in embed.

Please help me in above points.

Thanks
Rahul Aggarwal
 

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.
Try...

Code:
Sub Button1_Click()
    Worksheets("Sheet1").OLEObjects.Add Filename:=Worksheets("Sheet1").Range("A1").Value, Link:=False, _
        DisplayAsIcon:=True, Left:=40, Top:=40, Width:=150, Height:=10
End Sub

Alternatively, it can be written as follows...


Code:
Sub Button1_Click()
    With Worksheets("Sheet1")
        .OLEObjects.Add Filename:=.Range("A1").Value, Link:=False, _
            DisplayAsIcon:=True, Left:=40, Top:=40, Width:=150, Height:=10
    End With
End Sub

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,215,420
Messages
6,124,800
Members
449,189
Latest member
kristinh

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