Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 268
  • Last Modified:

How to identify the newest window in PowerPoint for Mac 2011

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
Bryce Bassett
Asked:
Bryce Bassett
  • 2
  • 2
1 Solution
 
Rgonzo1971Commented:
Hi,

Do you get more than one window  with

newdeck.Windows.Count

newdeck.Windows(1).Activate

Regards
0
 
JSRWilsonCommented:
Or maybe
newdeck.Windows(1).ViewType = ppViewNormal
0
 
Bryce BassettFreelance VBA programmerAuthor Commented:
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
 
JSRWilsonCommented:
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
 
Bryce BassettFreelance VBA programmerAuthor Commented:
Brilliant!   DoEvents did the trick   After that I can manipulate newdeck.windows(1) as expected.  Thanks a million
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now