M
MMC Monster
Hi.
I've created a small macro that adds a different way to insert symbols
at the current cursor position in a Power Point 2000 presentation.
My problem (right now, at least. ) is that if I run my macro and
there's no cursor, the macro crashes, saying:
Run-time error '-2147188160 (80048240)':
Selection (unknown member): Invalid request. Nothing appropriate is
currently selected.
The function I use to add text is:
Set InsertedText = _
ActiveWindow.Selection.TextRange.InsertSymbol( _
FontName:="Symbol", CharNumber:=Str(31 + 5 * 28 + 5), _
Unicode:=msoFalse)
My question: Is it possible to have the menu item for my macro be
greyed-out when there's no valid current cursor position?
Following is what I currently have in my Autpen and Auto_Close functions.
Thanks for any help.
Sub Autpen()
Dim NewControl As CommandBarControl
' Store an object reference to a command bar.
Dim ToolsMenu As CommandBars
' Figure out where to place the menu choice.
Set ToolsMenu = Application.CommandBars
' Create the menu choice. The choice is created in the first
' position in the Tools menu.
Set NewControl = ToolsMenu("Insert").Controls.Add _
(Type:=msoControlButton, _
Before:=5)
' Name the command.
NewControl.Caption = "Insert S&ymbol Macro"
' Connect the menu choice to your macro. The OnAction property
' should be set to the name of your macro.
NewControl.OnAction = "PowerPoint2000InsertSymbol"
End Sub
Sub Auto_Close()
Dim oControl As CommandBarControl
Dim ToolsMenu As CommandBars
' Get an object reference to a command bar.
Set ToolsMenu = Application.CommandBars
' Loop through the commands on the tools menu.
For Each oControl In ToolsMenu("Insert").Controls
' Check to see whether the comand exists.
If oControl.Caption = "Insert S&ymbol Macro" Then
' Check to see whether action setting is set to ChangeView.
If oControl.OnAction = "PowerPoint2000InsertSymbol" Then
' Remove the command from the menu.
oControl.Delete
End If
End If
Next oControl
End Sub
I've created a small macro that adds a different way to insert symbols
at the current cursor position in a Power Point 2000 presentation.
My problem (right now, at least. ) is that if I run my macro and
there's no cursor, the macro crashes, saying:
Run-time error '-2147188160 (80048240)':
Selection (unknown member): Invalid request. Nothing appropriate is
currently selected.
The function I use to add text is:
Set InsertedText = _
ActiveWindow.Selection.TextRange.InsertSymbol( _
FontName:="Symbol", CharNumber:=Str(31 + 5 * 28 + 5), _
Unicode:=msoFalse)
My question: Is it possible to have the menu item for my macro be
greyed-out when there's no valid current cursor position?
Following is what I currently have in my Autpen and Auto_Close functions.
Thanks for any help.
Sub Autpen()
Dim NewControl As CommandBarControl
' Store an object reference to a command bar.
Dim ToolsMenu As CommandBars
' Figure out where to place the menu choice.
Set ToolsMenu = Application.CommandBars
' Create the menu choice. The choice is created in the first
' position in the Tools menu.
Set NewControl = ToolsMenu("Insert").Controls.Add _
(Type:=msoControlButton, _
Before:=5)
' Name the command.
NewControl.Caption = "Insert S&ymbol Macro"
' Connect the menu choice to your macro. The OnAction property
' should be set to the name of your macro.
NewControl.OnAction = "PowerPoint2000InsertSymbol"
End Sub
Sub Auto_Close()
Dim oControl As CommandBarControl
Dim ToolsMenu As CommandBars
' Get an object reference to a command bar.
Set ToolsMenu = Application.CommandBars
' Loop through the commands on the tools menu.
For Each oControl In ToolsMenu("Insert").Controls
' Check to see whether the comand exists.
If oControl.Caption = "Insert S&ymbol Macro" Then
' Check to see whether action setting is set to ChangeView.
If oControl.OnAction = "PowerPoint2000InsertSymbol" Then
' Remove the command from the menu.
oControl.Delete
End If
End If
Next oControl
End Sub