Home | PowerPoint | PowerPoint Programming

PowerPoint Programming

Everything about PowerPoint programming including VBA, VSTO, and more.

See Also:
PowerPoint and Presenting Blog
PowerPoint and Presenting Notes



Product Showcase



Friday, April 26, 2013
posted by Geetesh at Friday, April 26, 2013 IST

First a little history -- look at our Stop Underlining Your Descenders! article -- of course, as per that article you can manually remove underlines from all characters such as g, j, p, q, and y that sport descenders. However, the task of individually selecting characters to remove underlines is fine if you need to do so for an important slide title or just your opening slide.

Remove Underlines from Descenders

What if you want to do the same task for an entire presentation, as shown in just one slide below?

Everything underlined

OK, we understand that no one has a complete presentation full of underlined text -- we are just exploring a proof-of-concept here! You'll soon realize that this is too much work to do! Especially since you can do this task in PowerPoint super-quickly using some simple VBA code, as Steve Rindsberg of PowerPoint FAQ explains.

First you need to know how you can run VBA scripts in PowerPoint -- then use this code. Explore the code a bit though since Steve has put in some helpful comments so that you can edit some values as required.

Sub FixAllDescenders()
' Removes underlines from all descenders in the presentation

    Dim oSl As Slide
    Dim oSh As Shape

    For Each oSl In ActivePresentation.Slides
        For Each oSh In oSl.Shapes
            If oSh.HasTextFrame Then
                If oSh.TextFrame.HasText Then
                    FixDescenders oSh
                End If
            End If
        Next
    Next

End Sub

Sub FixDescenders(oSh As Shape)
' Removes underlines from descenders in just the current shape

    Dim x As Long
    Dim oChar As TextRange
    With oSh
    If .HasTextFrame Then
    If .TextFrame.HasText Then
      For x = 1 To Len(.TextFrame.TextRange.Text)
        If IsDescender(Mid$(.TextFrame.TextRange.Text, x, 1)) Then
          .TextFrame.TextRange.Characters(x, 1).Font.Underline = False
        End If
      Next
    End If
    End If
    End With
End Sub

Function IsDescender(sCharacter As String) As Boolean
    Dim sDescenders as String
    sDescenders = "gjpqy"
    If InStr(sDescenders, sCharacter) > 1 Then
        IsDescender = True
    Else
        IsDescender = False
    End If
End Function

Once you have placed this code in the VBA editor, close the window to get back to your PowerPoint window. Before you proceed further, it's a great idea to save your file -- be sure to save as a PowerPoint Macro-Enabled Presentation with the PPTM file extension. If you save as any of the other file formats, PowerPoint will offer to remove the macros, and then of course the code to change embedded videos to linked will not work! See our PowerPoint File Formats page to learn about these file formats.

Then open or switch to the presentation with the embedded videos and run the macro. To do that, press the Alt+F8 shortcut key. In the Macro dialog box that appears, next to Macro in: choose All open presentations, as shown in the figure below. Click the FixAllDescenders Macro name, and then click the Run button.



The code looks at underlined text throughout your presentation, and removes underlines from characters that have descenders. In fact Steve made the code flexible enough so that you could add exceptions or include some other characters too! This code is also available on Steve's site -- and he will update it as required.

Look at the figure below to see the same slide we explored earlier on this page -- the slide below has underlines removed from characters with descenders.

Everything underlined

Thank you so much, Steve.

We tested this code using PowerPoint 2010 for Windows. Also, we have not checked this on PowerPoint 2013 for Windows (or 2011 for Mac) -- if you do, and it does work or not -- then we request you leave a comment below this post and share your thoughts. Of course you should share your thoughts even if you are a Windows user.



Steve RindsbergSteve Rindsberg has been associated with PowerPoint since the product originated more than two decades ago -- his PowerPoint FAQ site is a treasure trove of PowerPoint information. When he's not updating his site, he's working on his popular PPTools add-ins for PowerPoint. Steve's also into a lot of print technology related stuff.

Labels: , , , ,

0 comments

Links to this post



Friday, November 16, 2012
posted by Geetesh at Friday, November 16, 2012 IST

PowerPoint Random Number GeneratorHave you created a huge monster PowerPoint file that's hundreds of megabytes in size or even a gigabyte? The culprit may be any videos you have inserted on your slides! In years gone by, I always recommended that users place their videos (or any other media or linked files) in the same folder as their PowerPoint presentations so that the links to video files worked when you moved the presentation to another computer. You could then just copy the entire folder to another computer!

PowerPoint 2010 changed everything! Rather than linking videos, the default option was now to embed the videos as part of your PowerPoint file. And that's how it has been for subsequent releases of PowerPoint, including version 2011 on Mac, and version 2013 on Windows.

Undeniably, this had its share of advantages -- no more missing videos, and you no longer need to create a folder. Yes, that's less housekeeping for you to do, but housekeeping does have its own share of benefits. For one, you don't end up with huge monster files!

Ideally, you can just delete all the video files, and then insert them again -- this time, you can opt to link files rather than embedding them. To do that, click the down arrow next to the Insert button, and you'll find an option to link rather than embed. Yes, I know that's not too obvious!


But what if you did not want to re-insert videos all over again? Then just copy all the videos to the same folder as your PowerPoint file, and then run this EmbeddedMoviesToLinkedMovies VBA snippet, graciously coded by Steve Rindsberg of PowerPoint FAQ. Thanks to Steve for allowing us to reproduce this code here. Steve adds that it's best that you do this only with a copy of your original file.

First you need to know how you can run VBA scripts in PowerPoint -- then use this code. Explore the code a bit though since Steve has put in some helpful comments so that you can edit some values as required. Most importantly, be sure to edit the path as directed in the comments, else this code won't work.

You can actually create a blank, new presentation and insert this code within the VBA editor. To learn how you bring up the VBA editor and add code, look at our VBA scripts in PowerPoint tutorial. Yes, it's not necessary that this code is placed in the same presentation as your embedded videos -- all you need to do is make sure that both presentations (the presentation with this code, and the presentation with the video clips) are open at the same time.

Sub EmbeddedMoviesToLinkedMovies()

Dim oSl As Slide
Dim oSh As Shape
Dim x As Long
Dim sPath As String

' Edit this to the path where vids are stored,
' path must end in backslash
sPath = "C:\Stuff\MovieStuff\ThisProjectsMovieStuff\"

For Each oSl In ActivePresentation.Slides
    For x = oSl.Shapes.Count To 1 Step -1
        Set oSh = oSl.Shapes(x)
        If oSh.Type = msoMedia Then
            If oSh.MediaType = ppMediaTypeMovie Then
                If oSh.MediaFormat.IsEmbedded Then
                    Debug.Print oSh.Name
                    Call ConvertToLinked(oSh, sPath)
                End If
            End If
        End If
    Next    ' Shape
Next    ' Slide

End Sub

Sub ConvertToLinked(oSh As Shape, sPath As String)

Dim oSl As Slide
Dim oNewVid As Shape
Dim x As Long
Dim lZOrder As Long

Set oSl = oSh.Parent
lZOrder = oSh.ZOrderPosition

Set oNewVid = oSl.Shapes.AddMediaObject2(sPath & oSh.Name, msoTrue, msoFalse, _
    oSh.Left, oSh.Top, oSh.Width, oSh.Height)

Do Until oNewVid.ZOrderPosition = lZOrder
    oNewVid.ZOrder (msoSendBackward)
Loop

oSh.Delete
End Sub

Once you have placed this code in the VBA editor, close the window to get back to your PowerPoint window. Before you proceed further, it's a great idea to save your file -- be sure to save as a PowerPoint Macro-Enabled Presentation with the PPTM file extension. If you save as any of the other file formats, PowerPoint will offer to remove the macros, and then of course the code to change embedded videos to linked will not work! See our PowerPoint File Formats page to learn about these file formats.

Then open or switch to the presentation with the embedded videos and run the macro. To do that, press the Alt+F8 shortcut key. In the Macro dialog box that appears, next to Macro in: choose All open presentations, as shown in the figure below. Click the EmbeddedMoviesToLinkedMovies Macro name, and then click the Run button.



Thank you so much, Steve.

We tested this code using PowerPoint 2010 for Windows. Also, we have not checked this on PowerPoint 2011 for Mac -- if you do, and it does work or not -- then we request you leave a comment below this post and share your thoughts. Of course you should share your thoughts even if you are a Windows user.



Steve RindsbergSteve Rindsberg has been associated with PowerPoint since the product originated more than two decades ago -- his PowerPoint FAQ site is a treasure trove of PowerPoint information. When he's not updating his site, he's working on his popular PPTools add-ins for PowerPoint. Steve's also into a lot of print technology related stuff.

Labels: , , , ,

0 comments

Links to this post



Friday, August 17, 2012
posted by Geetesh at Friday, August 17, 2012 IST

Jamie GarrochJamie Garroch, CEO of GMARK Ltd., founded the company in 2009 to provide presentation professionals with PowerPoint software, content and training. Jamie uses PowerPoint for most of his graphic needs -- for everything from designing logos to creating web banners and even printed marketing collaterals. He also uses PowerPoint as a programming environment to create custom programming procedures and PowerPoint add-ins.

In this conversation, Jamie discusses what the upcoming PowerPoint 2013 offers developers, and about the rumours that apps will replace add-ins soon.

Geetesh: Office 2013 seems to be adding several new options for PowerPoint developers -– can you share some thoughts?

Jamie: The biggest change for developers in the Office 2013 Preview the addition of what Microsoft are calling "apps for Office". This shouldn't be confused with add-ins as the two are very distinct in both their purpose and development implementation. Apps for Office are essentially web applications and they offer some amazing new potential for developers familiar with web based environments such as XML, HTML, CSS, JavaScript and more. With the technology comes a new business model where apps can be published in a new Microsoft Store (making Office Marketplace obsolete), in exchange for 20% commission (the developer gets 80%) which is pretty generous compared with other stores.

But there's a snag. For an as yet unknown reason, PowerPoint 2013 Preview is not supporting any of this even if Excel and Word are!

So, the answer for PowerPoint developers is much simpler as we can only deal with the topic of 'traditional' add-ins. Microsoft provide seven new features for add-in developers on their new MSDN page, and since Steve Rindsberg has commented on four of them in this conversation, I'm going to pick these two:

  1. Theme Manipulation: There are a lot of new additions here that will allow developers to build add-ins that can open, edit and apply Themes. Recall that Theme files (.THMX) work across Office suite programs and help define a global visual style to documents. You could conceive an add-in that opens a Theme file, provides the user with the ability to graphically browse the various Theme variants in the Theme file (half are 16:9 format in PowerPoint 2013 and the other half 4:3), edits one or more elements of the Theme (color, fonts, effects) and then applies the selection to the current presentation or any other presentation on disk.

  2. Shape Events: Events allow developers to run pre-defined code when that event happens. The simplest type of event we can imagine when a user clicks a mouse but other invisible events are happening all the time in the background such as an event that fires when a presentation is opened or just before it's saved. One of the two new events, the .AfterShapeSizeChange event does exactly what it says in that it fires when a user changes the size of a shape in the slide edit mode. This could be used to trigger code to validate the change against a set of design rules for a corporate template (we often see people changing the size of a title placeholder or text box to try to squeeze more text on a slide!).

Geetesh: What's all this talk about the new Office apps replacing add-ins? Will add-ins continue to work in PowerPoint 2013?

Jamie: Apps for Office are not a replacement for add-ins but Microsoft's way of extending the power of the Office suite to enable rich web based applications. Let me take the analogy of a car. First we had wind down windows (excuse the pun!) to to keep us cool and then came air-con but air-con didn't replace the window, it complemented it and we still need both.

In the same way, add-ins provide developers with a great way to extend the functionality of the Office suite program itself, such as making it easier to align and position shapes, or converting presentations to other formats. Add-ins often build on the core Microsoft feature set of the Office client (the software that you install on your computer; PowerPoint, Word, Excel etc.) by adding new custom Ribbon tabs, groups and buttons which providing access to features Microsoft don't want or need to develop.

Conversely, web apps (not on your computer but in the cloud) will allow developers to make it much easier for an Office suite program to garner the power of the web, to interact with services previously very complex to implement in the add-in model. For example, let's say you're creating a document and you need a map of the world or a vector image of an animal. You might try the built in Microsoft picture features but you may also subscribe to an online service which provides just the right vector graphics you're looking for, without having to open up your web browser. In this case, it makes much more sense for the app to communicate with a service in the cloud rather than being 'static' on your computer.

For now, PowerPoint 2013 has been left out in the cold but my guess is it's just been a question of priorities and apps for Office will come in a future upgrade, maybe even within an Office Service Pack.

But whatever happens, add-ins are here to stay and will continue to sit well alongside their new sibling, web apps. And just in case there's any doubt, we've already tested our add-ins with PowerPoint 2013 Preview and all is working well.

Labels: , , ,

0 comments

Links to this post



Monday, August 13, 2012
posted by Geetesh at Monday, August 13, 2012 IST

Steve RindsbergSteve Rindsberg has been associated with PowerPoint since the product originated more than two decades ago -- his PowerPoint FAQ site is a treasure trove of PowerPoint information. When he's not updating his site, he's creating new PowerPoint add-ins that expand possibilities within PowerPoint. Steve's also into a lot of print technology related stuff.

In this conversation, Steve discusses what the upcoming PowerPoint 2013 offers developers, and about the rumours that apps will replace add-ins soon.

Geetesh: PowerPoint 2013 seems to be adding several new options for developers -- can you share some thoughts?

Steve: I am assuming this question is about what is new for developers in PowerPoint 2013, and what can Indezine readers and other PowerPoint users can expect to see in PowerPoint add-ins as a result.

The features that hold the most promise, at least to me, are:

  1. Presentation Broadcasting: Add-ins should be able to launch, pause and resume broadcast presentations and even add meeting notes to the broadcast.

  2. Guides: Developers can now add, delete and position drawing guides. How about an add-in that lets you create a set of guides -- and then memorize it. You could then recall it, or any other "guide set" you've created, with a click of the mouse?

  3. Commenting: It's been expanded to allow replying to comments and accessing these replies. I can imagine an add-in that would extract all the comments in a presentation and show them to the user in a more organized way than we now have.

  4. Charting: There are some interesting-looking new features here, but as yet they don't appear to be "wired up" yet. The new AddChart2 method seems to be better at producing error messages than charts, but I'm hoping that it and the other new features will enable us to add and manipulate charts without Excel flashing in and out of view as currently happens.

There’s a list of the new goodies for developers here: What's new for PowerPoint 2013 developers, including lots of links to online documentation of new objects, methods and properties; hardly any of these have any useful information yet, but I expect they’ll be fleshed out as the release date gets closer and features are locked in.

Geetesh: What's all this talk about the new Office apps replacing add-ins? Will add-ins continue to work in PowerPoint 2013?

Steve: When Ms. Foley says "...add-ins are passé. Apps are in." she's telling us more about the world Microsoft wants us to move into than the world we'll actually live in, at least for the next version or two of Office. And for PowerPoint users, the story's completely different. PowerPoint 2013 doesn't support the new add-in model Foley writes about. Office apps won't replace "traditional" PowerPoint add-ins just yet.

The story for traditional add-ins promises to have a happy beginning and ending. I've been testing all of my PPTools add-ins in Office 2013 (in the Click To Run version, no less). They all work nicely. In fact, I've updated the installers so anyone can test PPTools add-ins while testing the Office 2013 Preview (and report bugs using the Contact link on every page of PPTools.com).

Naturally, I can't speak for all add-ins, and in fact some of them are almost certain to have issues with the Click To Run version of Office 2013, but Microsoft and the developers will probably sort these out by the time Office 2013 releases.

Labels: , , ,

0 comments

Links to this post



Friday, July 20, 2012
posted by Geetesh at Friday, July 20, 2012 IST

Do you want to remove all animations from your slides? You may want to remove animations for a variety of reasons: maybe the sequencing is all messed up, and starting all over again seems like a great idea. But one look at your Animations task pane reveals tens or hundreds of animations on each slide. Is there a magic button somewhere in PowerPoint that can get rid of all animations all together?

Yes, you can do this easily in PowerPoint using some simple VBA code, as John Wilson of PowerPoint Alchemy explains. John adds that this only removes animations from individual slides, and not any animations added within the Slide Master.

First you need to know how you can run VBA scripts in PowerPoint -- then use this code. Explore the code a bit though since John has put in some helpful comments so that you can edit some values as required.

Sub Zap_Animations() 
Dim oeff As Effect 
Dim i As Integer 
Dim t As Integer 
Dim osld As Slide 
'Remove normal animations
For Each osld In ActivePresentation.Slides 
For i = osld.TimeLine.MainSequence.Count To 1 Step -1 
osld.TimeLine.MainSequence(i).Delete 
Next i 
'Remove triggers
For i = osld.TimeLine.InteractiveSequences.Count To 1 Step -1 
For t = osld.TimeLine.InteractiveSequences(i).Count To 1 Step -1 
osld.TimeLine.InteractiveSequences(i).Item(t).Delete 
Next t 
Next i 
Next osld 
End Sub 

Once you have placed this code in the VBA editor, close the window to get back to your PowerPoint slides. Before you proceed further, it's a great idea to save your file -- be sure to save as a PowerPoint Macro-Enabled Presentation with the PPTM file extension or PowerPoint Macro-Enabled Show with the PPSM extension. If you save as any of the other file formats, PowerPoint will offer to remove the macros, and then of course the Zap_Animations macro will not work! See our PowerPoint File Formats page to learn about these file formats.

Thereafter run the macro -- more info can be found in our Use Macros and Scripts in PowerPoint tutorial.

Thank you so much, John.

We tested this code using PowerPoint 2010 for Windows.



John WilsonJohn Wilson is a Microsoft PowerPoint MVP who creates some cool add-ins for PowerPoint. He participates in the PowerPoint newsgroups and runs the PowerPoint Alchemy site. John is based out of UK, and loves to hear from PowerPoint users about concepts and ideas to create even more PowerPoint add-ins!







Labels: , , , ,

1 comments

Links to this post








Follow Indezine
Share This Page
Bookmark and Share
Translate Page


Like This Page
Like This Site



Archives:

March 2009  |   April 2009  |   July 2012  |   August 2012  |   November 2012  |   April 2013  |  



  Microsoft and the Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.


Plagiarism will be detected by Copyscape


  ©2000-2012, Geetesh Bajaj. All rights reserved.

    since November 02, 2000