change active window

T

theintern

I have some vba that runs some queries in Access, opens up microsoft project,
does some stuff in project, and then opens up Powerpoint and does some stuff
there too. this is all possible because i've included the references, so i
can build this into just one module. the problem however is that my PP code
using the ActiveWindow.Presentation.Slides(1) command and at that time PP
isn't the active window. How do i specifically set the active window to be
PowerPoint?

thanks
Scott
 
T

theintern

here is the code with everything i've tried commented out.

Public Function TriFilter2()

Dim Continue As Integer
Dim pr As MSProject.Application
Dim pp As Object
Dim ppwindow As PowerPoint.DocumentWindow
Dim oPres As PowerPoint.Presentation
Dim waitTime As Integer
Dim waitTime2 As Integer

'Puts it in an infinite loop
Continue = 1
'Runs appropriate queries (which create tables), then opens Project
'and PowerPoint
While Continue = 1
DoCmd.SetWarnings False
DoCmd.OpenQuery "SMquery", acViewNormal, acEdit
DoCmd.OpenQuery "SMdelete", acViewNormal, acEdit
DoCmd.OpenQuery "PIPquery", acViewNormal, acEdit
DoCmd.OpenQuery "PIPdelete", acViewNormal, acEdit
DoCmd.OpenQuery "PLBquery", acViewNormal, acEdit
DoCmd.OpenQuery "PLBdelete", acViewNormal, acEdit
Set pr = New MSProject.Application
'pr.Visible = True
pr.FileOpen ("U:\Estimating Log\Est Schedule\Take-offbackup.mpp")
ImportAll
Set pp = CreateObject("powerpoint.application")
pp.Visible = True
pp.Presentations.Open FileName:="C:\Documents and
Settings\deckers\Desktop\ScheduleOutputbackup.pptm"
'Set oPres = PptApp.Presentations.Open("C:\Documents and
Settings\deckers\Desktop\ScheduleOutputbackup.pptm")
'pp.Active = True
'Set ppwindow = pp.Presentation.Window
'Set ActiveWindow.Caption = "ScheduleOutputbackup.pptm"
'Set ActiveWindow = pp.Presentation.Window
'pp.Activate
'Presentations.Activate
'ActiveWindow = Powerpoint.ActivePresentation.Windows(1)
CreateShow
DoCmd.SetWarnings True
Wend

End Function
 
T

theintern

Also, within the CreateShow sub is where the problem is. see below:

Sub CreateShow()
'Declare the variables
Dim oSlide As Slide
Dim oPicture1 As Shape
Dim oPicture2 As Shape
Dim oPicture3 As Shape
Dim oPicture4 As Shape
Dim oPicture5 As Shape
Dim oPicture6 As Shape
'Dim oPres As PowerPoint.Presentation
'Powerpoint.Application.Activate
'Set oPres = PowerPoint.Presentations(1)
'oPres.Application.Activate

DisplayAlerts = False
ScreenUpdating = False


'**********
'PICTURE 2
'**********
' Change slide index position to the first slide
'HAS PROBLEM WITH THE FOLLOWING LINE OF CODE; THE ACTIVE WINDOW IS 'NOT
POWERPOINT
ActiveWindow.View.GotoSlide 2

' Set oSlide to the first slide in the presentation.
Set oSlide = ActiveWindow.Presentation.Slides(2)

' Set oPicture to the picture file on your computer. Set Link To
' File to false, Save With Document to true, and place it in the
' upper left-hand corner of the slide, sized to 1 by 1 points.
Set oPicture2 = oSlide.Shapes.AddPicture("U:\Estimating Log\Est
Schedule\Directory\TOT\ALLTwoWeeks.gif", _
msoFalse, msoTrue, 1, 1, 1, 1)
' Now scale the picture to full size, with "Relative to original
' picture size" set to true for both height and width.
oPicture2.ScaleHeight 1, msoTrue
oPicture2.ScaleWidth 1, msoTrue

'MORE CODE AFTER THAT, BUT NEVER MAKES IT ANY FARTHER

End Sub

' Move the picture to the center of the slide. Select it.
With ActivePresentation.PageSetup
oPicture2.Select
End With
'Sizes the photo to span the entire width
With ActiveWindow.Selection.ShapeRange(1)
oPicture2.LockAspectRatio = msoFalse
oPicture2.Left = 0
oPicture2.Top = 0
oPicture2.Width = 720
End With
 
T

theintern

so...Set oPres = pp.Presentations.Open("C:\Documents and
Settings\deckers\Desktop\ScheduleOutputbackup.pptm") worked, but i had
trouble passing it to CreateShow. yes, create show is another sub below this
one that does some stuff in powerpoint (including starting the show). which
is why i need the window active, or another solution to insert pictures, i.e.
Set oSlide = ActiveWindow.Presentation.Slides(1)
Set oPicture1 = oSlide.Shapes.AddPicture("U:\Estimating Log\Est
Schedule\Directory\TOT\ALLThreeWeeks.gif", _
msoFalse, msoTrue, 1, 1, 1, 1)

if i could pass oPres to CreateShow, then i think i could use
oPres.slides(1), but right now it's not letting me do that.

right now i can't use
oPres.SlideShowWindow.Activate
because either there is no slideshowwindow in the main sub, or in the
CreateShow sub it doesn't know what oPres is because i'm having trouble
passing it.

thanks!
scott
 
T

theintern

thanks steve. that works great. i thought i tried this already, but i must
have been screwing something up. thanks for the help.

scott
 
T

theintern

actually, i take that back. it doesn't work. false alarm. it's still
giving me the error "Object doens't support this property or method." is
there some reference check box i need to have checked? i think i have all
the PowerPoint references checked, and ActiveX 2.0. any ideas?

thanks
scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top