Pre-recorded Macro Suddenly Crashing

Hal Vaughan <[email protected]> Thu, 16 Jun 2011 06:16:00 -0400
Newsgroups gmane.comp.openoffice.devel.api
Message-ID <[email protected]>
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 =3D ThisComponent.CurrentController.Frame
'	MsgBox "Debug 2"
	oDispatch =3D 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 t=
hat call other subroutines:

	HalLib.AutoTextMacro.InsertAutoMacroText()
	Margin4()

Are part of an auto-text setup I use where I can define keys to type out ch=
aracter 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 (Ma=
rgin4()) 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 sa=
me library and also reads the user fields in the document.  The routine I w=
as 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 hi=
ts 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--=20
-----------------------------------------------------------------
To unsubscribe send email to [email protected]
For additional commands send email to [email protected]
with Subject: help