04-20-2014, 01:24 AM
Hello All,
I found a very useful piece of VBA code that I am able to run in PPT (Alt-F8, choose VBA sub name) which imports a bunch of pictures from a folder, 1 image per slide, full screen:
This works fine but is not that useful for automation because I have to make sure macros enabled, click Alt-F8, choose sub name, etc.
I would much rather drive ppt from QM.
Is the above even possible to do through VBA in QM? I have tried a little VBA in outlook from QM but can't seem to see how to convert the VBA:
I got this far:
Macro Macro12
but then could not figure out how to format the slide add picture like this as in the VBA script:
Error in Macro12: Expected 7 arguments, not 1.
Shape AddPicture(BSTR'FileName LinkToFile SaveWithDocument FLOAT'Left FLOAT'Top [FLOAT'Width=-1] [FLOAT'Height=-1]) ;;LinkToFile: msoTrue msoFalse msoCTrue msoTriStateToggle msoTriStateMixed ;;SaveWithDocument: msoTrue msoFalse msoCTrue msoTriStateToggle msoTriStateMixed
etc....
Any formatting hints?
Thanks,
S
I found a very useful piece of VBA code that I am able to run in PPT (Alt-F8, choose VBA sub name) which imports a bunch of pictures from a folder, 1 image per slide, full screen:
Quote:Sub ImportFullScreen()
Dim strTemp As String
Dim strPath As String
Dim strFileSpec As String
Dim oSld As Slide
Dim oPic As Shape
' Edit these to suit:
strPath = "C:\Image Import Folder\"
strFileSpec = "*.jpg"
strTemp = Dir(strPath & strFileSpec)
Do While strTemp <> ""
Set oSld = ActivePresentation.Slides.Add(ActivePresentation.Slides.Count + 1, ppLayoutBlank)
Set oPic = oSld.Shapes.AddPicture(FileName:=strPath & strTemp, _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=0, _
Top:=0, _
Width:=0, _
Height:=0)
' Reset it to its "real" size
With oPic
.ScaleHeight 1, msoTrue
.ScaleWidth 1, msoTrue
End With
With oPic
Dim appssw, appssh
appssw = ActivePresentation.PageSetup.SlideWidth
appssh = ActivePresentation.PageSetup.SlideHeight
.LockAspectRatio = msoTrue
If oPic.Width / oPic.Height > appssw / appssh Then
.Width = appssw
.Top = (appssh - oPic.Height) / 2
Else
.Height = appssh
.Left = (appssw - oPic.Width) / 2
End If
End With
strTemp = Dir
Loop
End Sub
This works fine but is not that useful for automation because I have to make sure macros enabled, click Alt-F8, choose sub name, etc.
I would much rather drive ppt from QM.
Is the above even possible to do through VBA in QM? I have tried a little VBA in outlook from QM but can't seem to see how to convert the VBA:
I got this far:
Macro Macro12
typelib PowerPoint {91493440-5A91-11CF-8700-00AA0060263B} 2.8
PowerPoint.Application ap._getactive;
int SlideCount = ap.ActivePresentation.Slides.Count
out SlideCount
int oSld = ap.ActivePresentation.slides.Add(SlideCount, ppLayoutBlank)
PowerPoint.Presentation pres
str strPath = "C:\Image Import Folder\"
PowerPoint.Slide Slide.Shapes.AddPicture(PicPath )
but then could not figure out how to format the slide add picture like this as in the VBA script:
Error in Macro12: Expected 7 arguments, not 1.
Shape AddPicture(BSTR'FileName LinkToFile SaveWithDocument FLOAT'Left FLOAT'Top [FLOAT'Width=-1] [FLOAT'Height=-1]) ;;LinkToFile: msoTrue msoFalse msoCTrue msoTriStateToggle msoTriStateMixed ;;SaveWithDocument: msoTrue msoFalse msoCTrue msoTriStateToggle msoTriStateMixed
etc....
Any formatting hints?
Thanks,
S