Embedded Object

Abhishek1988

New Member
Joined
Oct 22, 2018
Messages
27
Hello everyone,

I am working on a UserForm where on click on button embedded objects will be open. I am using below codw for this which is working fine. However i want objects (workbook) should open as read only so no one can edit the same. Pls help

Private Submit_click ()

If cmbox.value = "Animal" then
Sheets ("Sheet2").OLEobjects("object 55"). Activate

End if

End sub
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hello everyone,

I am working on a UserForm where on click on button embedded objects will be open. I am using below codw for this which is working fine. However i want objects (workbook) should open as read only so no one can edit the same. Pls help

Private Submit_click ()

If cmbox.value = "Animal" then
Sheets ("Sheet2").OLEobjects("object 55"). Activate

End if

End sub

Are you opening workbook files ?

If you know the files path, can't you just use the Workbooks.Open ReadOnly=TRUE method ?
 
Upvote 0
Yes we are opening.. but it's based on objects bcoz there are lot's of objects. If it would be workbook open. Then what would be code then?
 
Last edited:
Upvote 0
Yes we are opening.. but it's based on objects bcoz there are lot's of objects. If it would be workbook open. Then what would be code then?

Something like this ;
Code:
 Workbooks.Open Filename:="[B]EnterYourFilePathNameHere[/B]", ReadOnly:=True

The path and file names you can find out about them by selecting the object and looking at the formula bar

I am assuming you are linking the workbooks not embeeding them .
 
Upvote 0
It's not working. can't i edit this code?

If cmbox.value = "Animal" then
Sheets ("Sheet2").OLEobjects("object 55"). Activate

and some read only code?
 
Upvote 0
It's not working. can't i edit this code?

If cmbox.value = "Animal" then
Sheets ("Sheet2").OLEobjects("object 55"). Activate

and some read only code?

Try this :
Code:
[COLOR=#333333]MsgBox  [/COLOR][COLOR=#333333]Sheets("Sheet2").OLEobjects("object 55").[/COLOR][COLOR=#333333]OLEType[/COLOR]
 
Upvote 0
on place of

Sheets ("Sheet2").OLEobjects("object 55"). Activate

i mentioned
MsgBox Sheets("Sheet2").OLEobjects("object 55").OLETyp, and it;s not working.
 
Upvote 0
on place of

Sheets ("Sheet2").OLEobjects("object 55"). Activate

i mentioned
MsgBox Sheets("Sheet2").OLEobjects("object 55").OLETyp, and it;s not working.

The reason I am asking is to establish whether the Oleobject is embedeed or linked .

If it is linked then you have a file path so you can easily use the Workbooks.Open ReadOnly method I suggested eralier on.

If you have an embedeed object on Sheet2 named object 55 then the following should work .. It should return 0 or 1.
Code:
MsgBox Sheets("Sheet2").OLEObjects("object 55").OLEType

Make sure you are passing the correct worksheet and object names .
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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