18

Problem definition

I have two usb microscope reading part and serial numbers. I want to control the display and recording of screen shots from Excel-VBA.

I would like to try this using the supplied VLC active X component. I need the finish product to be a single zip that does not need to be installed. I think using this activex object as a registration-free COM is the way to go.

References

I have been doing my homework, here are my references.

How to use vlc.dll without registration?

Registration-Free COM Interop

VLC Player and Excel Visual Basic Editor

Cannot get registration-free COM working from VBA

My attempt so far.

I created Desktop\excel vlc demo\excel vlc demo.xlsb I then copied the entire vlc distribution to Desktop\excel vlc demo\vlc\

This includes axvlc.dll and axvlc.dll.manifest

I created a module and put this code in.

Sub VLC()
    Dim actCtx As Object
    Set actCtx = CreateObject("Microsoft.Windows.ActCtx")
    actCtx.Manifest = ThisWorkbook.Path & "\vlc\axvlc.dll.manifest"

    Dim myVlC As Object
    Set myVlC = actCtx.CreateObject("AXVLC.VLCPlugin2")

    myVlC.Visible = True
    myVlC.playlist.Add (ThisWorkbook.Path & "\demo.mov")
    myVlC.playlist.Play

End Sub

This fails at the line

    Set myVlC = actCtx.CreateObject("AXVLC.VLCPlugin2")

with error

    Run-time error '429':
    ActiveX component can't create object

It is possible I have the wrong object name "AXVLC.VLCPlugin2", I could not confirm if it is still valid in the documentation.

It could also be that "user1610015" is correct in saying that "I don't think you can make reg-free COM work in this case"

At this point I am out of ideas, I never tried reg-free COM before so I don't know if I'm doing something wrong with the reg-free COM or the axvlc part !

thanks

EDIT 1: Attempt with early binding

I went in tool -> references, then clicked browse and added the axvlc.dll file. I modified the code as follows (the AXVLC.VLCPlugin2 part auto-completed so at least this part should work)

Sub VLC()
    Dim myVlC As New AXVLC.VLCPlugin2
    myVlC.Visible = True
    myVlC.playlist.Add (ThisWorkbook.Path & "\demo.mov")
    myVlC.playlist.Play

End Sub

However this fails with the same error

    Run-time error '429':
    ActiveX component can't create object

on the line

myVlC.Visible = True

Perhaps I also need to register this file with regsrv32 ? EDIT 2: tried regsvr32

ran this command from the vlc subfolder

regsvr32 axvlc.dll

I got a msgbox saying this command ran successfully, however I get the same error.

Mesut Akcan
  • 899
  • 7
  • 19
Shodan
  • 1,065
  • 2
  • 13
  • 35
  • 5
    It simply doesn't work with late binding. See [this answer](http://stackoverflow.com/a/39176974/4088852) for the explanation. – Comintern Sep 02 '16 at 21:04
  • I tried early binding, I tried to register with regsvr32 (it succeeded) however I get the same error (see updated question text). – Shodan Sep 02 '16 at 23:23
  • That's bizarre. You actually don't need to register it if you add a reference BTW. I almost wonder if the the `AXVLC.VLCPlugin2` isn't creatable. Now I'm going have to download and install it... :-P – Comintern Sep 02 '16 at 23:27
  • OK, installed and played with. I can't replicate the issue though - the code runs just fine. It appears to need a host window though. – Comintern Sep 02 '16 at 23:58
  • Did you run the installer or just used the files from the zip ? What do you mean by a host window ? I created a UserForm and ran this code but I get "invalid class string" Set myVlC = UserForm1.Controls.Add("AXVLC.VLCPlugin2", "test1", True) – Shodan Sep 03 '16 at 00:29
  • I ran the installer. It lets me *try* to add it as a UserForm control, but that gives an unspecified error. When I try to add it as a Worksheet control it crashes Excel. It's apparently pretty tweaky. Check out [this link](https://social.msdn.microsoft.com/Forums/en-US/baec16d1-e85c-4be9-8751-966bef527756/vlc-player-and-excel-visual-basic-editor?forum=isvvba). Most of the recommendations I've run across are to use the legacy `VLCPlugin` interface instead of the `VLCPlugin2` interface, but I can't get the `addTarget` method to take any input. – Comintern Sep 03 '16 at 00:44
  • ^^^ That link has the same error you're getting BTW. – Comintern Sep 03 '16 at 00:44
  • if using late binding for vlc activex, you should not use "AXVLC.VLCPlugin2". instead use "VideoLAN.VLCPlugin.2" – Shafeek Aug 22 '17 at 05:59
  • I know i'm late with this, but... have you seen this: [Resolved - VLC ActiveX Control](http://www.vbforums.com/showthread.php?622179-RESOLVED-VLC-ActiveX-Control) ? – Maciej Los Jul 13 '18 at 11:13

1 Answers1

1

I had problems using VLC with Excel inserting vlc player onto a sheet and form.

It worked last year... the "VLC Activex Plugin...." was not in the additional controls box to select. Registering the dll was successful but still did not work. Then I remembered i upgraded VLC to new version and 64Bit

I uninstalled VLC 64 and installed new version 32 bit the "VLC Activex Plugin...." was Now in the additional controls box all good