none
Excel VBA Shockwave Object RRS feed

  • Question

  • In Excel 2013 I created a user form with a shockwave flash object. The Excel I was using allowed me to do this because I added the reference to the shockwave library and created a YouTube player. I removed the reference to the shockwave library and it works fine on the computer that I created the workbook on. Now when I pass this workbook to other Excel users (2013 or 2016) they get the message "cannot load an object because it is not available on this machine" and eventually get a ADO error and crashes excel.

    What I would prefer to do is, on the workbook open event is to test if  the computer has the shockwave/flash installed so that the object loads without error or, if that object cannot be found/loaded stop the ADO error message/process and display a Excel message box when the user attempts to open the form with that object, or install/load that object at open for that workbook.
    Friday, May 12, 2017 2:28 PM

All replies

  • Hi,

    You could check reference's name via iterating through VBE's reference. Here is the example

    Dim flag As Boolean
    flag = False
    For i = 1 To Application.VBE.ActiveVBProject.References.Count
    If Application.VBE.ActiveVBProject.References(i).Name = "ShockwaveFlashObjects" Then
    flag = True
    Exit For
    End If
    Next i
    MsgBox IIf(flag, "ShockwaveFlash is refered", "ShockwaveFlash is not refered")

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

    Monday, May 15, 2017 3:17 AM
    Moderator
  • Celeste thanks for the reply. Your code does a great job detecting if indeed the ShockwaveFlash reference is checked in the reference list but I need to go one step prior. As mentioned earlier I do not have a reference to shockwave. To create the SWF object I simply added an additional control, the "shockwave flash controll" to my toolbox to create the SWF object. My workbook operates fine on All Excel versions that have the Flash Player installed. My workbook will be sent to other Excel users of which some may have flash installed and is available in Excel and, other users may not have flash installed. If the users that do not have flash installed open my workbook they immediately receive the Microsoft Forms error message "Could not load an object because it is not available on this machine." What I'm trying to do is to detect upon opening the workbook is to determine if that particular version of Excel (2013-2016) indeed has Flash installed and if not trap that Microsoft Forms error message and clear that error message process and display a new excel message and possibly inform my users that my form with the SWF object is not available until Flash is installed because when the Microsoft Forms message is displayed it removes the SWF object from my form and I need to keep the object in that form until the user installs the Flash player. If the user attempts to use that form without Flash being installed I'd like to send a message that flash needs to be installed to use this feature. Thank you.


    • Edited by CPAHBL Wednesday, May 17, 2017 5:49 PM
    Wednesday, May 17, 2017 5:45 PM