[Last Call] Learn how to a build a cloud-first strategyRegister Now


Powerpoint VBA: Clear all formatting from a string

Posted on 2005-04-21
Medium Priority
Last Modified: 2012-05-05
Excel has a great WorksheetFunction called .clean which strips all nonprintable characters from a string.  Does Powerpoint have anything comparable, or can you suggest a macro that will do this in Powerpoint XP (i.e., vbTab, vbCrLf, etc)?
Question by:lpupa

Accepted Solution

david_barker earned 1000 total points
ID: 13853202
Add this function to a module in VBA :

Public Function Clean(ByVal sString As String) As String
  Dim iChar As Integer
  Dim iCode As Integer
  Clean = ""
  For iChar = 1 To Len(sString)
    iCode = Asc(Mid$(sString, iChar, 1))
    If iCode >= 32 And iCode <= 126 Then Clean = Clean + Chr$(iCode)
  Next iChar
End Function

You can then test it with :

Public Sub Test()
  sString = Clean("ABC" & vbTab & vbCrLf & "ETR")
  ' sString now contains only "ABCETR"
End Sub


Author Comment

ID: 13882837
Testing this little function head to head with calling Excel from Powerpoint, both "cleaned" the string text equally well.
The function ran in 1/10 the time it took to automate Excel and run WorksheetFunction.Clean.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

825 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