Discussion:
Pre-recorded Macro Suddenly Crashing
Hal Vaughan
2011-06-16 10:16:00 UTC
Permalink
I've been using this macro for a good while:

sub CharacterName
Dim oDoc As Object
Dim oDispatch As Object
BasicLibraries.LoadLibrary("HalLib")
HalLib.AutoTextMacro.InsertAutoMacroText()
Margin4()
' MsgBox "Debug 1"
oDoc = ThisComponent.CurrentController.Frame
' MsgBox "Debug 2"
oDispatch = createUnoService("com.sun.star.frame.DispatchHelper")
' MsgBox "Debug 3"
oDispatch.executeDispatch(oDoc, ".uno:GoToStartOfLine", "", 0, Array())
' MsgBox "Debug 4"
oDispatch.executeDispatch(oDoc, ".uno:EndOfLineSel", "", 0, Array())
MsgBox "Debug 5"
oDispatch.executeDispatch(oDoc, ".uno:ChangeCaseToUpper", "", 0, Array())
MsgBox "Debug 6"
oDispatch.executeDispatch(oDoc, ".uno:GoToEndOfLine", "", 0, Array())
' MsgBox "Debug 7"

End Sub

The debugging statements were not in there until recently. The two lines that call other subroutines:

HalLib.AutoTextMacro.InsertAutoMacroText()
Margin4()

Are part of an auto-text setup I use where I can define keys to type out character names when I'm writing a script. The first pulls the name out of a user field in the document and enters it in the document. The 2nd one (Margin4()) changes the margins.

The line I'm having problem with is right after the "Debug 5" statement:

oDispatch.executeDispatch(oDoc, ".uno:ChangeCaseToUpper", "", 0, Array())

Now this is crashing my program every single time. A few hours ago it was working perfectly. Then I was trying to modify a routine that is in the same library and also reads the user fields in the document. The routine I was working on does not change anything the above routine uses.

I've changed the routine I'm editing back to what it was originally. (The original statements were just commented out, so I just uncommented them and commented out the changes.) But I still get a crash whenever the macro hits this line.

I was wondering if something could have changed, so I tried to record a new macro, and I can't.


Any thoughts on why the ChangeCaseToUpper would suddenly not work?


Thanks!


Hal--
-----------------------------------------------------------------
To unsubscribe send email to dev-***@api.openoffice.org
For additional commands send email to ***@api.openoffice.org
with Subject: help

Loading...