Solved

How to identify the newest window in PowerPoint for Mac 2011

Posted on 2014-09-03
5
256 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 50

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you how to use shortcut menus in the Access run-time environment.
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
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.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

828 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