Is there a way to embed the videofile within excel, then simply hide the worksheet it is embedded in?
There are many ways to do what you want in addition to the examples below. You can put the file name in the Spreadsheet or Hard Code the File Name in the Code.
Sub WindowsMediaPlayerUrlExamples()
Dim sVideoFileName As String
Dim sPathAndVideoFileNameCombination As String
'Load the Video File (from line 332 in code module 'ModMain' for Windows Media Player on the Spreadsheet) or
'Load the Video File (from line 197 in code module 'ModUserFormSplashScreen' for Windows Media Player on the UserForm)
myControl.Url = sPathAndVideoFileNameCombination
'or
myControl.Url = "C:\Users\Owner\Documents\ExcelAndVba\abc.mp4"
'or to use the same folder as the file that contains the code
sVideoFileName = "abc.mp4"
sPathAndVideoFileNameCombination = ThisWorkbook.Path & "\" & sVideoFileName
myControl.Url = sPathAndVideoFileNameCombination
'or to use the same folder as the file that contains the code and get the file name from the spreadsheet
sVideoFileName = ThisWorkbook.Sheets("SheetXYZ").Range("D4").Value
sPathAndVideoFileNameCombination = ThisWorkbook.Path & "\" & sVideoFileName
myControl.Url = sPathAndVideoFileNameCombination
'or to get the folder and file name from the spreadsheet using an intermediate value (easier to debug)
sPathAndVideoFileNameCombination = ThisWorkbook.Sheets("SheetXYZ").Range("D4").Value
myControl.Url = sPathAndVideoFileNameCombination
'or to get the folder and file name from the spreadsheet directly (not recommended - difficult to debug)
myControl.Url = ThisWorkbook.Sheets("SheetXYZ").Range("D4").Value
End Sub
The following tips may help you.
To enable Macros and to Run Macros see the following:
http://office.microsoft.com/en-us/ex...010031071.aspx
http://office.microsoft.com/en-us/ex...010014113.aspx
If help is still needed do a google search for 'youtube excel enable macro' and/or 'youtube excel run macro'.
To access Visual Basic (VBA) see:
http://www.ablebits.com/office-addin...a-macro-excel/
a. Click on any cell in the Excel Spreadsheet (may not be needed).
b. ALT-F11 to get to VBA.
c. CTRL-R to get project explorer (if it isn't already showing).
d. Double Click on a 'Module Name' in 'Project Explorer' to see code for that module.
Debugger Secrets:
a. Press 'F8' to single step (goes into subroutines and functions).
b. Press SHIFT 'F8' to single step OVER subroutines and functions.
c. Press CTRL 'F8' to stop at the line where the cursor is.
d. 'Left Click' the margin to the left of a line to set (or clear) a BREAKPOINT.
e. Press CTRL 'G' to open the IMMEDIATE WINDOW. 'debug.print' statements send their
output to the IMMEDIATE WINDOW.
f. Select View > Locals to see all variables while debugging.
g. To automatically set a BREAKPOINT at a certain location put in the line:
'Debug.Assert False'
h. To conditionally set a BREAKPOINT at a certain location put in lines similar to:
if i >= 20 and xTV20 > 99.56 then
Debug.Assert False
endif
i. A variable value will be displayed by putting the cursor over the variable name.
To manually set a breakpoint, see http://www.wiseowl.co.uk/blog/s196/breakpoints.htm
Lewis
Bookmarks