Need help with macro to insert a symbol character

K

Kim

I have a macro I use in Word to insert a symbol at the cursor
insertion point. Here is the macro:

Sub Minus()
'
*********************************************************************
' Toolbar Item:
' -- Minus
'
*********************************************************************

' Insert minus symbol
Selection.InsertSymbol Font:="Symbol", characternumber:=-4051,
unicode:= _
True

End Sub

I need to use this same macro in PowerPoint, but the code isn't
working. Can someone provide me the coding? I'm new to ppt VBA.

Thanks,
Kim
 
K

Kim

Does this do it?

Sub Insert_minus()
On Error Resume Next
With ActiveWindow.Selection.TextRange.Characters
.Text = Chr$(45)
.Font.Name = "Symbol"
End With
End Sub

--
john ATSIGN PPTAlchemy.co.uk

Free PPT Hints, Tips and Tutorialshttp://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html
PPTLive Atlanta Oct 11-14 2009










- Show quoted text -

Wow! That worked perfectly! I was looking for other mathmatical
symbols to insert, like the muliplication, greater than, less than,
1/8, 3/8, 5/8, etc., all symbols that are not listed in the CHR code
listing. Can this macro be modified to insert any of these symbols?

Thanks again for your help!
 
K

Kim

Something like this:

With ActiveWindow.Selection.TextRange
   .InsertSymbol FontName:="Arial Unicode MS", _
    CharNumber:=452, Unicode:=True
End With

But in PPT, there's not necessarily a current selection, and the
selection may not always be text, so you'd want to surround that with a
few tests like:

    With ActiveWindow.Selection
        ' IS there a current selection
        ' and is it text?
        If .Type = ppSelectionText Then
            With .TextRange
              ' do stuff
            End With
        End If
    End With

==============================
PPT Frequently Asked Questionshttp://www.pptfaq.com/

PPTools add-ins for PowerPointhttp://www.pptools.com/

Don't Miss the PPTLive User Conference! Atlanta | Oct 11-14- Hide quoted text -

- Show quoted text -

This really has helped me a lot! My final macro looked like this:

Sub Minus()
'
' Inserts minus than symbol'
With ActiveWindow.Selection.TextRange
.InsertSymbol FontName:="Symbol", _
CharNumber:=45, Unicode:=msoTrue
End With
End Sub

I didn't need the error message (at least not at the moment!)

Thanks again for all of your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top