Closing SlideMaster, PowerPoint 2007

Jack21
2StarLounger
Posts: 107
Joined: 23 Mar 2010, 13:42

Closing SlideMaster, PowerPoint 2007

Post by Jack21 »

Can anyone help please?

I have a piece of code in VB.Net that populates information into the SlideMaster of a presentation. The issue I have is that once the information has been populated the SlideMaster does not close and revert back to Normal view.

The code is held in a class of general functions where I pass in the presentation. Is there a way of changing the view to Normal using the presentation. I have taken a look and it appears that I can change the WindowState but only using the application.

Thanks in advance.
Jack

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Closing SlideMaster, PowerPoint 2007

Post by HansV »

In Visual Basic, it isn't necessary to switch to Master view in order to manipulate the master. You can set text, add shapes etc. directly, without changing the view.
Best wishes,
Hans

Jack21
2StarLounger
Posts: 107
Joined: 23 Mar 2010, 13:42

Re: Closing SlideMaster, PowerPoint 2007

Post by Jack21 »

The design company who put the Presentation I need to include in this solution have placed the copyright in the Master so that users cannot delete. I need to check the information and change if they necessary.

Regards
Jack

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Closing SlideMaster, PowerPoint 2007

Post by HansV »

I'm not sure I understand.

You can do something like this without actually displaying the slide master:

ActivePresentation.SlideMaster.HeadersFooters.Footer.Text = "Eileen's Lounge 2010"

or

ActivePresentation.SlideMaster.Shapes.AddLine 10, 100, 400, 100
Best wishes,
Hans

Jack21
2StarLounger
Posts: 107
Joined: 23 Mar 2010, 13:42

Re: Closing SlideMaster, PowerPoint 2007

Post by Jack21 »

I can access the SlideMaster (as this is the only location I can make the change on that particular textbox), cycle through until I find the appropriate textbox, update the information. The problem I have is that the rest of the code runs, task pane closes but I am left in the newly created PowerPoint presentation in SlideMaster view rather than Normal view.

Thanks
Jack

User avatar
StuartR
Administrator
Posts: 12577
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Closing SlideMaster, PowerPoint 2007

Post by StuartR »

Jack21 wrote:...I am left in the newly created PowerPoint presentation in SlideMaster view rather than Normal view...
Jack,

If you want to change the slide master from VBA then there is absolutely no need to go in to SlideMaster view, you can just use appropriate code to change the slide master while remaining in Normal view.

It might help if you post the code you are using here.
StuartR


Jack21
2StarLounger
Posts: 107
Joined: 23 Mar 2010, 13:42

Re: Closing SlideMaster, PowerPoint 2007

Post by Jack21 »

I think I might be confusing matters !! This is the piece of code I call:

Public Shared Sub populatePresentationFooter(ByVal strName As String, ByVal prePresentation As PowerPoint.Presentation, ByVal strPresentationTitle As String, ByVal _userManager As UserManager)

For lngCount As Integer = 1 To prePresentation.SlideMaster.Shapes.Count
Dim strText As String = prePresentation.SlideMaster.Shapes(lngCount).TextFrame.TextRange.Text
If strText = "© 2010 Smith LLP. Private and confidential." Then
For lngProfile As Integer = 0 To _userManager.Profiles.Count - 1
If _userManager.Profiles(lngProfile).Name = strName Then
Dim strCopyright As String = "© " & Format(Date.Today, "yyyy") & " " & _userManager.Profiles(lngProfile).LegalEntity & ". All rights reserved."
prePresentation.SlideMaster.Shapes(lngCount).TextFrame.TextRange.Text = strCopyright
End If
Next
End If
Next

End Sub

This works perfectly well but, as mentioned, the SlideMaster view stays open once the presentation has populated.

Regards
Jack

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Closing SlideMaster, PowerPoint 2007

Post by HansV »

Unfortunately, the ViewType property is read-only in PowerPoint VBA, so you can't change it to set normal view.
There's some tricky code for PowerPoint 2002/2003 in How to activate the tab of choice (Outline/Slides) in PowerPoint 2002 and later but I don't know how to modify that for PowerPoint 2007.
Best wishes,
Hans

User avatar
StuartR
Administrator
Posts: 12577
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Closing SlideMaster, PowerPoint 2007

Post by StuartR »

Jack21 wrote:...This works perfectly well but, as mentioned, the SlideMaster view stays open once the presentation has populated...
I can't test that code as I don't have the matching context, but if I run a simplified version that just does

Code: Select all

Sub Text()
    Dim strCopyright As String
    strCopyright = "Test text for footer"
    ActivePresentation.SlideMaster.Shapes(4).TextFrame.TextRange.Text = strCopyright
End Sub
then it works fine, without leaving the SlideMaster view open. Can you single step your code and work out which line is switching the view to SlideMaster view.
StuartR


Jack21
2StarLounger
Posts: 107
Joined: 23 Mar 2010, 13:42

Re: Closing SlideMaster, PowerPoint 2007

Post by Jack21 »

Feel free to call me names like "stupid, idiot etc " !!!!

The original Blank.potx file opens in SlideMaster, hence when my presentation creates it defaults to SlideMaster ..... what can I say, what a fool !!

Thanks for your help though.
Jack

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Closing SlideMaster, PowerPoint 2007

Post by HansV »

Things like that happen to all of us! Thanks for letting us know.
Best wishes,
Hans

User avatar
StuartR
Administrator
Posts: 12577
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Closing SlideMaster, PowerPoint 2007

Post by StuartR »

Jack21 wrote:Feel free to call me names...
Mistakes like this are too easy to make for any of us to dare call you names. The important thing is that you keep investigating till you realise what is happening.

Thanks for letting us know the outcome.
StuartR