简体   繁体   English

从 Excel VBA 使用 VLC 播放电影

[英]Play movie using VLC from Excel VBA

I'm trying to create an excel vba program/macro that will start a movie stored locally on my hard-drive in vlc player using the vlc activex plug-in (axvlc.dll).我正在尝试创建一个 excel vba 程序/宏,它将使用 vlc activex 插件 (axvlc.dll) 在 vlc 播放器中启动存储在本地硬盘驱动器上的电影。 I'm able to register vlc so it appears in my Project References.我可以注册 vlc,所以它出现在我的项目参考中。 I'm also able to see AXVLC in the "Object Browser".我还可以在“对象浏览器”中看到 AXVLC。 But I can't get any code to work that doesn't give "Run-time error '429': ActiveX component can't create."但我无法让任何不会出现“运行时错误‘429’:ActiveX 组件无法创建”的代码工作。 I'm using Excel 2016 and VBA 7.1.我正在使用 Excel 2016 和 VBA 7.1。

Sub Button1_Click()
   Dim myVlC As Object
   Set myVlC = CreateObject("AXVLC.VLCPlugin2")
   myVlC.Visible = True
   myVlC.playlist.Add ("test.mkv")
   myVlC.playlist.Play
End Sub

I tried to follow the conversation here... Using VLC player activex within excel vba as a registration-free COM and here... https://social.msdn.microsoft.com/Forums/en-US/baec16d1-e85c-4be9-8751-966bef527756/vlc-player-and-excel-visual-basic-editor?forum=isvvba with no success.我试图在这里关注对话...... 在excel vba中使用VLC播放器activex作为免注册COM ,在这里...... https://social.msdn.microsoft.com/Forums/en-US/baec16d1-e85c- 4be9-8751-966bef527756/vlc-player-and-excel-visual-basic-editor?forum=isvvba没有成功。

I've created a lot of simple macros, but never anything using ActiveX, or anything really this object oriented before.我创建了很多简单的宏,但从来没有使用过 ActiveX,或者任何真正面向对象的宏。 Any help will be greatly appreciated.任何帮助将不胜感激。

Public Sub Start_VLC()
'its working for me...
    Dim strProgramName As String
    Dim strArgument As String
    Dim strLoc As String

    strLoc = Worksheets("dbFilmes").Cells(2, 6).Value 'film location
    strProgramName = "C:\Program Files\VideoLAN\VLC\vlc.exe" 'vlc location
    strArgument = strLoc 'film location

    Call Shell("""" & strProgramName & """ """ & strArgument & """", vbNormalFocus)
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM