Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Opening a RealVideo file in a VB application

Posted on 1999-07-17
Medium Priority
Last Modified: 2010-04-30
 I would like to make some sort of interactive picture library. But I would also like to add some videos in it. I compressed them in Real Video but I can't make them play from a VB application. All I want is a command_Button that open RealPlayer and AUTOMATICALLY starts playing my Video.
Question by:mikezk
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

Vbmaster earned 60 total points
ID: 1525520
You can use the ShellExecute API, add this code to your form (if you want to add it to a modal just replace the Private to Public).

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Function Run(ByVal strFilePath As String, ByVal strParms As String, ByVal strDir As String) As String
  'Run the Program and Evaluate errors
  Select Case ShellExecute(0, "Open", strFilePath, strParms, strDir, SW_SHOW)
  Case 0
    Run = "Insufficent system memory or corrupt program file"
  Case 2
    Run = "File not found"
  Case 3
    Run = "Invalid path"
  Case 5
    Run = "Sharing or Protection Error"
  Case 6
    Run = "Seperate data segments are required for each task"
  Case 8
    Run = "Insufficient memory to run the program"
  Case 10
    Run = "Incorrect Windows version"
  Case 11
    Run = "Invalid program file"
  Case 12
    Run = "Program file requires a different operating system"
  Case 13
    Run = "Program requires MS-DOS 4.0"
  Case 14
    Run = "Unknown program file type"
  Case 15
    Run = "Windows program does not support protected memory mode"
  Case 16
    Run = "Invalid use of data segments when loading a second instance of a program"
  Case 19
    Run = "Attempt to run a compressed program file"
  Case 20
    Run = "Invalid dynamic link library"
  Case 21
    Run = "Program requires Windows 32-bit extensions"
  Case Else
    Run = ""
  End Select

End Function

Now whenever you want to run a file that is associated with RealPlayer you can use the code

  Me.Caption = Run(Filename, "", "")

This will execute whatever program that is associated with the file extension of filename so you can use this code for any other file too. The function will return a empty string if everything went okay, if not it will return a string with a short description of what went wrong.


Author Comment

ID: 1525521
When I insert this fonction into my program and that I try to execute Me.caption = ("e:\video.ra","","") VB says that SW_SHOW is not declared.

Expert Comment

ID: 1525522
Oh i missed that one, add

Private Const SW_SHOW = 5

where you declared the ShellExecute API.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question