On Jun 26, 2009, at 7:45 AM, Fernand Vanrie wrote:
when len(sChar) = 0 then you get the error
I had been checking for what sChar is, but kept forgetting to check
for it's length. Thanks.
I also realized I had made another goof. I intended to limit the
length of key phrases to 32 characters. While I checked for the
length, I forgot to keep increasing the length of the text I'm
comparing!
Hal
Hal,
you have getposition and jumptostartofpage to compare the 2 positions
hope it helps
Fernand
Vaughan wrote:
I have a macro collection I've posted about before. It works like
the AutoCorrect function, but I've customized it for me. If I hit
Ctrl-Shift-T (actually Command-Shift-T since I'm now on an iMac),
I get a dialog that lets me define a key phrase and the AutoText
that goes with it. Then when I'm writing, after any space or at
the start of a new line, I hit Command-T. That activates a macro
that starts at the current cursor position and steps back until it
finds a space or a control character. The only problem with this
is if I do this at the start of a document I end up with a null
character or something instead and I can't do a comparison on it.
So is there some way, after moving the cursor, to check and see if
I'm at the start of the document?
The code that steps backwards through the characters in the
document is below. Notice that all I do is step back, check each
new character added to the start of the selection and see if the
value is that of a space or less. I want to add an If statement
before I move the cursor left so if I'm trying to move it past the
start of the document, I can catch it.
Of course, another alternative is to be able to define a variable
to whatever character I'd find at the start of the document and
compare sChar to that value to see if I'm at the start.
Sub InsertAutoMacroText
oDoc = ThisComponent
oCurs = oDoc.getCurrentController().getViewCursor()
iEnd = false
iCount = 0
Do
'Go back one character, then get that character and put it in a
separate variable
'for comparison.
oCurs.goLeft(1, true)
sKey = oCurs.getString()
sChar = Left(sKey, 1)
'BUG: This next line throws an error if we try to use this at the
start of a
'document.
iChar = Asc(sChar)
' MsgBox "String: " + sKey + ", Char: " + sChar + ", Char
Code: " + iChar
If iChar < 33 Then iEnd = true
If iCount > 32 Then iEnd = true
Loop Until iEnd
oCurs.goRight(1, true)
sKey = oCurs.getString()
' sText = "Replaced ->" + sKey + "<-"
sText = GetDocumentVariable(sKey)
oCurs.setString(sText)
oCurs.collapseToEnd()
End Sub
I've been going through the API, but I have a disadvantage: I
haven't been working with it much recently, so I don't seem to
find things as easily as I have in the past.
Any help on this is much appreciated!
Hal
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]