Solved

How to identify the newest window in PowerPoint for Mac 2011

Posted on 2014-09-03
5
253 Views
Last Modified: 2014-09-05
Hopefully a simple question.  VBA macro on a toolbar in PowerPoint for Mac 2011.  I create a new document based on a template, then want to manipulate the newly created window.  The new document opens fine, but its window is NOT automatically the active window.  I've tried to address newdeck.windows(1), application.windows(1), or application.windows(application.windows.count), but none of them seems to work.  How can I reliably identify the window just created with the new document?

Sub NewPresentation()

Dim newdeck As Presentation

file2open = contentlibraryfolder & ":Templates:HPC Template.potx"

Set newdeck = Application.Presentations.Open(fileName:=file2open, Untitled:=msoTrue)

'HERE IS WHERE I AM ASSUMING THE NEWEST CREATED WINDOW (NEWDECK) SHOULD BE THE ACTIVEWINDOW, BUT NOT SO

ActiveWindow.ViewType = ppViewNormal
ActiveWindow.View.Zoom = 100
ActiveWindow.WindowState = ppWindowMaximized

End Sub

Open in new window

0
Comment
Question by:versatilebb
  • 2
  • 2
5 Comments
 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 40302857
Hi,

Do you get more than one window  with

newdeck.Windows.Count

newdeck.Windows(1).Activate

Regards
0
 
LVL 23

Expert Comment

by:JSRWilson
ID: 40303933
Or maybe
newdeck.Windows(1).ViewType = ppViewNormal
0
 

Author Comment

by:versatilebb
ID: 40305104
Still not working correctly.   Here are some additional clues.  

Just after creating newdeck, if I try this:
newdeck.Windows(1).ViewType = ppViewNormal
newdeck.Windows(1).View.Zoom = 100
newdeck.Windows(1).WindowState = ppWindowMaximized

Open in new window

I get a silly error that says "Integer out of range.  1 is not in the valid range of 1 to 0."

Just after creating newdeck, if I insert: "MsgBox newdeck.Windows.Count" it displays "0".  Then when I close the msgbox, the rest of the code executes correctly, whether I use
newdeck.Windows(1).ViewType = ppViewNormal
newdeck.Windows(1).View.Zoom = 100
newdeck.Windows(1).WindowState = ppWindowMaximized

'OR

ActiveWindow.ViewType = ppViewNormal
ActiveWindow.View.Zoom = 100
ActiveWindow.WindowState = ppWindowMaximized=

Open in new window

Weird.  Something about the msgbox is kicking the tires and forcing newdeck to become the active window.  But of course I don't want the user to have to close a msgbox.   I tried opening a modeless dummy form, then closing it, but it still freezes the action.   Any other suggestions for a workaround for what seems to be a bug?
0
 
LVL 23

Accepted Solution

by:
JSRWilson earned 500 total points
ID: 40305654
I'm not a Mac user so don't know if you can do this on a Mac but try replacing the msgBox line with DoEvents
0
 

Author Closing Comment

by:versatilebb
ID: 40307195
Brilliant!   DoEvents did the trick   After that I can manipulate newdeck.windows(1) as expected.  Thanks a million
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This article will show you how to use shortcut menus in the Access run-time environment.
Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now