Using VLC player activex within excel vba as a registration-free COM

旧城冷巷雨未停 提交于 2019-12-09 10:07:05

问题


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.

来源:https://stackoverflow.com/questions/39300607/using-vlc-player-activex-within-excel-vba-as-a-registration-free-com

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!