2 Macro Questions:

M

MMC Monster

Hi.
I've created a MS Word macro in VBA, that I've been using in Word 2000
almost since it came out (I had updated the macro from previous versions
of word). The macro creates a text input box and will insert a
character at the current text position dependant on the text box user input.

I have two questions about bringing this macro into Powerpoint 2000:

1. Can I create a macro that is loaded up with *all* powerpoint
presentations, or does it have to be manually installed in each
presentation? In MS Word 2000, I could put the macro in normal.dot,
which would then let it be run in any open document.

2. Can someone tell me what's wrong with the following code snipet? It
works fine in Word2000 but fails in PowerPoint2000:

Private Sub SYMBOLHeart()
Selection.InsertSymbol Font:="Symbol", CharacterNumber:=Str(31 + 4
* 28 + 26), Unicode:=0
End Sub ' SYMBOLHeart
 
S

Shyam Pillai

1. You need to create an add-in. This will ensure the macro is available to
all the open presentations.
PowerPoint Addin FAQ
http://www.mvps.org/skp/ppafaq.htm

2. Note that code that runs in Word is not going to work directly in
PowerPoint. It's a different program so you need to modify the code
accordingly.
ActiveWindow.Selection.TextRange.InsertSymbol FontName:="Symbol",
CharNumber:=Str(31 + 4 * 28 + 26), Unicode:=msoFalse


--
Regards
Shyam Pillai

Handout Wizard
http://www.mvps.org/skp/how/
 
M

MMC Monster

1. You need to create an add-in. This will ensure the macro is available to
all the open presentations.
PowerPoint Addin FAQ
http://www.mvps.org/skp/ppafaq.htm

Thanks for the tip. I'll check it out. :)
2. Note that code that runs in Word is not going to work directly in
PowerPoint. It's a different program so you need to modify the code
accordingly.
ActiveWindow.Selection.TextRange.InsertSymbol FontName:="Symbol",
CharNumber:=Str(31 + 4 * 28 + 26), Unicode:=msoFalse

I always thought that Office 2000 used Visual Basic for applications (as
opposed to Word Basic, which Office '95 used) and that allowed most
functions to be ported without much alteration. Bummer. :-(
 
M

MMC Monster

1. You need to create an add-in. This will ensure the macro is available to
all the open presentations.
PowerPoint Addin FAQ
http://www.mvps.org/skp/ppafaq.htm

2. Note that code that runs in Word is not going to work directly in
PowerPoint. It's a different program so you need to modify the code
accordingly.
ActiveWindow.Selection.TextRange.InsertSymbol FontName:="Symbol",
CharNumber:=Str(31 + 4 * 28 + 26), Unicode:=msoFalse

I had time to try out the code snippet, and it seems to do most of what
I want done. One question, though. After the code runs, the inserted
text is then selected, so if the user hits a key it will be erased. How
can I make the text unselected, preferably with the cursor immediately
after the inserted character?
 
M

MMC Monster

1. You need to create an add-in. This will ensure the macro is available to
all the open presentations.
PowerPoint Addin FAQ
http://www.mvps.org/skp/ppafaq.htm

2. Note that code that runs in Word is not going to work directly in
PowerPoint. It's a different program so you need to modify the code
accordingly.
ActiveWindow.Selection.TextRange.InsertSymbol FontName:="Symbol",
CharNumber:=Str(31 + 4 * 28 + 26), Unicode:=msoFalse

I had time to try out the code snippet, and it seems to do most of what
I want done. One question, though. After the code runs, the inserted
text is then selected, so if the user hits a key it will be erased. How
can I make the text unselected, preferably with the cursor immediately
after the inserted character?
 
M

MMC Monster

1. You need to create an add-in. This will ensure the macro is available to
all the open presentations.
PowerPoint Addin FAQ
http://www.mvps.org/skp/ppafaq.htm

2. Note that code that runs in Word is not going to work directly in
PowerPoint. It's a different program so you need to modify the code
accordingly.
ActiveWindow.Selection.TextRange.InsertSymbol FontName:="Symbol",
CharNumber:=Str(31 + 4 * 28 + 26), Unicode:=msoFalse

I had time to try out the code snippet, and it seems to do most of what
I want done. One question, though. After the code runs, the inserted
text is then selected, so if the user hits a key it will be erased. How
can I make the text unselected, preferably with the cursor immediately
after the inserted character?
 
T

Tim Hards

Hi MMC Monster,
This should move the text cursor to the position after the inserted
symbol:

Private Sub SYMBOLHeart()
Dim InsertedText As TextRange
Dim Pos As Integer
Dim ShapeTextFrame As TextFrame
Dim ShapeText As TextRange

Set InsertedText = _
ActiveWindow.Selection.TextRange.InsertSymbol( _
FontName:="Symbol", _
CharNumber:=Str(31 + 4 * 28 + 26), _
Unicode:=msoFalse)
Pos = InsertedText.Start

Set ShapeTextFrame = ActiveWindow.Selection.TextRange.Parent
Set ShapeText = ShapeTextFrame.TextRange
ShapeText.Characters(Pos + 1, 0).Select

End Sub ' SYMBOLHeart
 

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