none
How to open an OLE object by Read-Only? RRS feed

  • Question

  • I have a button [DisplayChart] in a PPT slide that embeds an Excel chart onto a slide using AddOLEObject.

    Set shapeOnPPT = 
    ActivePresentation.Slides.FindBySlideID(mySlideID).Shapes.AddOLEObject(Left:=100,_
    Top:=100, Width:=500, Height:=400, FileName:="c:\ThisDoc\Tester123.xlsx", Link:=msoTrue)

    Problem

    When I go into presenter view and click the [DisplayButton] and Tester123.xlsx is opened by another user, the PPT would 'hang'. Then I noticed that an Excel app has opened with this prompt message:

    enter image description here

    Clicking Read-Only or Notify closes the Excel app and PPT would not hang anymore.

    What I've tried

    I figured that I need to open testing.xlsx as Read-Only automatically. According to Microsoft's documentation, it seems like I can use the Link parameter.

    Determines whether the OLE object will be linked to the file from which it was created. If you specified a value for ClassName, this argument must be msoFalse.

    However, changing this parameter to msoTrue or msoFalse still does not solve anything.

    P.s. In Windows 7, this problem does not occur. I'm currently using Windows 10.

    Wednesday, May 3, 2017 1:37 AM

Answers

  • The answer is to change the read-only status to read-only using SetAttr with vbReadOnly. With this, the file can be accessed without any problems via multiple users.
    • Marked as answer by equals2nine Monday, July 17, 2017 9:14 AM
    Monday, July 17, 2017 9:14 AM

All replies

  • Hello,

    What is your Office version? 

    According to the message, please visit Excel file is locked out for editing to another user.

    Could you reproduce the issue for a new created excel file? Please make sure the file is closed before linking it.

    Since the method does not provide any parameter to open the file in read-only mode, to fix it, you may check if the file is opened before adding it as an OLE object.

    Please visit Macro code to check whether a file is already open to see a good sample.

    Regards,

    Celeste

     

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, May 4, 2017 6:16 AM
    Moderator
  • The answer is to change the read-only status to read-only using SetAttr with vbReadOnly. With this, the file can be accessed without any problems via multiple users.
    • Marked as answer by equals2nine Monday, July 17, 2017 9:14 AM
    Monday, July 17, 2017 9:14 AM