Assign Format|Default to Keyboard

Use Tools|Configure Tab: Keyboard to assign StarOffice-Functions to Keyboard-Shortcuts. If you are looking for Format|Default you will not be able to find it. The reason is resetting the attributes depends on the selected object. This function is available e.g. if some portion of text is highlighted but not if a text frame is selected. The good news is, you can assign Format|Default to a Keyboard-Shortcut using a macro.

Let's record a macro:

Highlight a piece of text and choose Tools|Macro.

Macro name: FormatStandard
Macro from: should already be set to soffice/Standard/Module1.

Use the Button Record to start the recording (you should see this tiny Window).
Now invoke Format|Default and stop the recording with the button above. That's it! Choose Tools|Macro, select FormatStandard in the listbox, press the button Assign and select a Keyboad-Shortcut of your choice (there is a second possibility using Tools|Configure).

Take a look at the recorded macro, choosing Tools|Macro and pressing the button Edit. The StarBasic-Editor should show a macro like the following one:

Sub FormatStandard 
Selection.ResetAttributes() 
End Sub

For sure you could type this few lines directly using the StarBasic-Editor. The main disadvantage of the small macro above is, it will not work with every kind of selection. If a picture is selected StarBasic will drop an Error-Message "Property or method not found" that confuses most StarOffice users. Why not resign this Error-Dialog and beep a warning instead?

Sub FormatDefault
   'Error Handling is dealt with in this subprocedure
   On Local Error Goto ErrorLabel
   'Here is our function to set default style
   Selection.ResetAttributes()
   'Cancel the subprocedure here. Do not run into the error handling code
   Exit Sub
   'Error handling stuff follows
ErrorLabel:
   'We are expecting the error "Property or method not found"
   'when a picture in a text document is selected.
   'This error has the number 423 (see Appendix ***)
   If Err() = 423 Then
      'This error is not serious. Just give a warning tone to say
      'that the macro is functioning
      Beep
   Else
   'Throw a generic error message in case of other errors
   MsgBox("By deleting all hard formatting" & chr(13) &_
          "the following error occurred:" & chr(13) &_
          Error() & chr(13) &_
          "Error number: " & Err() ,_
          16,"Macro Error")
   Endif
End Sub


Author: Werner Roth Original page http://www.wernerroth.de/en/staroffice/tips

© 2000 Legal Notice