I am creating a powerpoint file and adding slides into it programmatically through Access-VBA and it is working fine till now. But Now, the client wants that the ppt should be invisible or minimized during generation only. Just after activating the ppt object, I set it minimized, but then also, during 'Slides.Add', it again pops up, so I need to minimize it again. The issue is that this causes cursor focus move to ppt instead of document he is working on. So, is there any way, I could completely keep it minimized or do this generation work in background and only open it once its done? The code I am using is:
Dim shpGraph As Object, Shpcnt As Integer, FndGraph As Boolean
Dim lRowCnt, lColCnt, lValue As Long, CGFF_FldCnt As Integer
Dim OPwrPnt As Object, OpwrPresent As Object, OpwrSlide As Object
Set OPwrPnt = CreateObject("Powerpoint.application")
Set OpwrPresent = OPwrPnt.Presentations.Add(WithWindow:=msoFalse)
Set OpwrSlide = OpwrPresent.Slides.Add(slideCounter, PpSlideLayout.ppLayoutTitle)
OPwrPnt.WindowState = ppWindowMinimized
slideCounter = slideCounter + 1
lheight = OPwrPnt.ActivePresentation.PageSetup.SlideHeight / 2
lwidth = OPwrPnt.ActivePresentation.PageSetup.SlideWidth / 1
LLeft = 0
lTop = OPwrPnt.ActivePresentation.PageSetup.SlideHeight / 4
Set shpGraph = OpwrPresent.Shapes.AddOLEObject(Left:=LLeft, _
Top:=lTop, Width:=lwidth, Height:=lheight, _
ClassName:="MSGraph.Chart", Link:=0).OLEFormat.Object
I have written the code to minimize the windowstate just before and after Add function, but still it pops up just for a fraction of second, hence moving the cursor focus from any document they are working to the ppt, which they dont want. So how can I keep it completely minimized?
You can open the powerpoint object without a window (assuming you never use Select
or any Active...
references
Set oPPTPres = oPPTApp.Presentations.add(WithWindow:=msoFalse)
then, adding slides to that presentation should be conducted completely invisibly. After that, I believe you will have to just save, close, and re-open the presentation (with the WithWindow
property set to true) to view it