Solved

How to identify the newest window in PowerPoint for Mac 2011

Posted on 2014-09-03
5
259 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:Bryce Bassett
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 52

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:Bryce Bassett
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:Bryce Bassett
ID: 40307195
Brilliant!   DoEvents did the trick   After that I can manipulate newdeck.windows(1) as expected.  Thanks a million
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

617 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