Reputation: 1
ActivePresentation.Slides(1).Shapes.AddMediaObject2(audioFileName, msoFalse, msoTrue, 50, 50, 50, 50) presents an error every single time, regardless of it having the full string including Filename:=, etc. It also will not work with AddMediaObject either.
This: ActivePresentation.Slides(1).Shapes.AddMediaObject2 audioFileName, msoFalse, msoTrue, 50, 50, 50, 50
does not throw a compiler error, but also does not work. I am incredibly confused, as this has been frustrating me for 3 days straight. I have searched and tried every format anyone has typed for this type of code, and I cannot for the life of me get it to work.
It does not work for audio OR video. Pictures work just fine with AddPicture, but it must be in a
ActivePresentation.Slides(1).Shapes.AddPicture Filename:=picFileName, LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, Left:=50, Top:=50, Width:=50, Height:=50
type format, and will NOT work with ( or ) surrounding the filename to height.
Also, the compiler error tells me to add an equal sign and a string... but at the END of the format with brackets. I have no idea what is going on.
Any help would be GREATLY appreciated.
Upvotes: 0
Views: 544
Reputation: 14809
.Add and many other methods can act as statements or functions.
ActivePresentation.Slides(1).Shapes.AddMediaObject2(audioFileName, msoFalse, ... etc etc (ie with the Parens after AddMediaObject2) is a function that will return a reference to the newly added media object so you need to do
Set SomeObject = ActivePresentation.Slides(1).Shapes.AddMediaObject2(audioFileName, msoFalse,
instead. Or leave out the the parens if you're not going to do anything with the returned object reference.
Your second syntax (w/o the parens) works here as long as I supply the full path to a valid media file, one that PPT is able to import on its own manually.
What error do you get when you run the code?
Upvotes: 0