Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

wmv in ms word

Posted on 2009-07-04
8
Medium Priority
?
1,327 Views
Last Modified: 2012-05-07
How is it possible to embed and play .wmv files in MS Word 2003?
thanks, Penelope
0
Comment
Question by:penelope112358
[X]
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
  • 5
  • 3
8 Comments
 
LVL 20

Expert Comment

by:darbid73
ID: 24778236
Yes - In short

On the View menu, point to Toolbars, and click Control Toolbox.
In the Control Toolbox, click More Tools.
In the list of available ActiveX Controls, click Windows Media Player.
Draw the control somewhere on your form.

Then you will need code like this



Const strPATHNAME As String = "C:\videos\"
'Change this line to the path where your movie files are stored.
'Be sure to include the trailing backslash!
 
Private Sub MediaPlayer1_EndOfStream(ByVal Result As Long)
'Check to see if the movie has ended. If so, then set the
'control's visibility to false and turn off autostart.
   Dim strName As String
 
   If Result = 0 Then
      strName = ""
      With MediaPlayer1
         .Visible = False
         .AutoStart = False
         .FileName = strName
      End With
      SlideShowWindows(1).View.GotoSlide 1, msoTrue
   End If
End Sub
 
Sub startme1()
'This is attached to an action button.
   Dim strName As String
   'Set the file name to movie you want to play
   strName = strPATHNAME & "movie1.avi"
   RunMovie strName
End Sub
 
Sub startme2()
'This is attached to an action button.
'You can have as many of these as you want.
'Just copy startme1 and paste into the project, but
'make sure you change the name of the subroutine.
   Dim strName As String
 
   'Set the file name to the movie you want to play.
   strName = strPATHNAME & "movie2.avi"
   RunMovie strName
End Sub
 
Sub RunMovie(strName As String)
'This function sets the various parameters, then resets
'the slide as the last step.
   With MediaPlayer1
      .AutoStart = True
      .DisplaySize = mpFullScreen
      'You can choose whatever size you want for the playback
      'of the movie with the .DisplaySize method.
 
      .Visible = True
      .EnableFullScreenControls = False
      .EnablePositionControls = False
      .EnableTracker = False
      .FileName = strName
   End With
   SlideShowWindows(1).View.GotoSlide 1, msoTrue
End Sub

Open in new window

0
 

Author Comment

by:penelope112358
ID: 24781232
Hello darbid73,

thanks for helping me with this and submitting detailed code. In startme2() I didn't use the & in the string name, just used &.

I was able to insert the plug in and attached your code in "This document" but can't get it to run, wonder what I might have overlooked. For your reference I have attached that document.


For the size I will experiment with these parameters:
mpFitToSize
mpFullScreen
1
2
3


Liglin


Sample-embedded.doc
0
 
LVL 20

Expert Comment

by:darbid73
ID: 24783242
Ok it has been a while, so throw out the code I gave you as that is for the old Media Player.

With yours it is probably very simple.

With this one I put the code in the open document routine otherwise it starts automatically.

This will let you click the play button if you want.

If you make other buttons for your word doc then you would need to change the path in this click routine and would need "WindowsMediaPlayer1.Controls.play" at the end to play it.  You will see at the end of "WindowsMediaPlayer1.Controls" that you can play and stop etc without using the buttons of the actual media player.



Private Sub Document_Open()
 
Dim strName As String
 
strName = strPATHNAME & "all.wmv"  'your file name
 
WindowsMediaPlayer1.windowlessVideo = True
WindowsMediaPlayer1.settings.autoStart = False   'stop it from automatically starting on load
 
WindowsMediaPlayer1.URL = strName   'add the path to your file
WindowsMediaPlayer1.settings.volume = 100      'here you can change initial volume
WindowsMediaPlayer1.settings.setMode "loop", False     'stop it from looping
 
End Sub

Open in new window

0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:penelope112358
ID: 24788051
Thanks for the new much simpler code. I have put the code into Microsoft Word Objects "ThisDocument" but the Object still won't run...


Sample-embedded.doc
0
 

Author Comment

by:penelope112358
ID: 24791768
Looking at the sample  I have included in the previous post, is it possible that I have perhaps attached the code incorrectly?
0
 
LVL 20

Accepted Solution

by:
darbid73 earned 500 total points
ID: 24791847
You are going to have to be more specific.

Go into the Visual Basic Editor and go Debug>Stepinto and then use F8 to step through the code.  Does anything give an error?

Can you play this file with this Media Player anyway? Like can you manually open and play this file?

Check your path is correct.  Open Windows explorer and navigate to this file then copy the path that is at the top of the Windows Exporer.
0
 

Author Comment

by:penelope112358
ID: 24801533
Thank you Darbid73. I got it to work. Great help!! You really made a difference!!!
0
 

Author Closing Comment

by:penelope112358
ID: 31599822
Excellent help!! Thanks again very much.
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

610 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