PDA

View Full Version : To create a video in a word document



gregy9
10-05-2009, 07:55 AM
Hello,

First of all, I am not a native english speaker, I hope it is not to painfull to read my post ...

I have an idea : I wish to put a video in a word document!

The document is made of few hundreds of pages. I would like to place in the margins of each page, at the same place for each page, an image taken from a video.


Once the book is printed, when I scroll it fast enougth I should be able to watch my video! :yes

The principle is funny but I encounter some problems :

1 I found (with the help of internet) how to select the pictures in some folder

2 I found how to insert the pictures always at the same place on a page

3 I found how to go to the next page

4 but step 2 and 3 do not seem to be compatible : the code select the pages but always puts the image on the first page. If I use "inlineshapes" in spite of "shapes" I lose the original layout... :banghead:


If you try the code below :
a/ Thanks for your help

b/ at the firts launch, the program ask you to select a file in a folder then crashes

b/ at the second or other next launches, the code try to insert all the files wich are present in the previously selected folder

c/ to change the folder, you will need to close then restart word

d/ dont try it with big pictures or more than 10 small pictures : the superposition of several pictures in word consumes a huge amount of memory



JI am pretty sure I am close to my goal but my knowledges of VBA syntax are actualy quite limited.

here is THE CODE :

Sub gg()

Dim fs, f, f1, fc, s
Dim i, NbPages As Long
NbPages = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)

With Dialogs(wdDialogFileFind)
.Display
ChangeFileOpenDirectory .SearchPath
Set fs = CreateObject("Scripting.FileSystemObject" )
Set f = fs.GetFolder(.SearchPath)
Set fc = f.Files
For Each f1 In fc 'loop on the images

For i = 1 To NbPages 'loop on the pages
With ActivePage.Shapes 'the problem is here...
.AddPicture _
FileName:=f1.Name, _
LinkToFile:=False, SaveWithDocument:=True, Left:=200, Top:=20
End With

Application.Browser.Next 'to get the next page

Next i
Next
End With

End Sub