Difficult to say why there is no answer, but I would guess that it is
probably because the people reading this list are not certain of the
answer. For example, consider the answer that I am providing:
Hal Vaughan wrote:
I write mainly screenplays, which have margin changes (which would be
paragraph indents in OOo). I've spent the past 7 years programming,
with little or no free time and now I finally have time to write a
script. Previously I used Word Perfect. I know I'll have to use
different key definitions, but essentially, under Word Perfect, I had 4
main macros, bound to the keys CTRL-1 to CTRL-4. All I had to do was
press one of those keys to set the margin. I know I can do the same
under OOo with margin changes.
I would probably use a specific paragraph style for the changes, and use
the key commands to set the paragraph style.
Now here's the more difficult part: When I'm writing dialog, the
character's name is in all caps, in the center of the page. I used to
set it up so ALT-A would center and print Anne, ALT-B would center and
print Bob and so on for all the characters I used a lot in my script.
This is where I'm running into problems. In Word Perfect all I had to
do was hit the keys to define a macro, hit the key I'm defining, then
press CTRL-4 and type the name of a character, then when done, hit
the "stop recording" key. Then the next time I hit the key, it calls
the CTRL-4 macro for the margin (actually to center the name), then
prints the name.
I know to bind a macro to a key I have to go through the menu, by hand,
which is 3-4 steps to get there. I also can't easily include one macro
in another macro.
It is easy to call one macro from another. For example:
Sub one
Print "One"
Call Two()
End Sub
Sub two
Print "Two"
End Sub
I expect that recording a macro will not follow things such as assigning
keys to a macro.
So here's what I'm thinking I'd like to do: Write a macro that would
prompt for specific text, then ask for the key I want to bind it to.
Once I enter both, it not only creates the macro on it's own
(automatically naming it), but also binds it to the key mentioned
(preferably only in that document). That way I can quickly define
macros on the go, while I'm writing, and just as quickly, in the same
process, define the key it is bound to.
I have no idea how to use a macro to bind a key combination to call a macro.
The next part, where do you store the text that you desire to
substitute. I assume that you will need to write a macro to insert the
text, and the text that is inserted will change. Because you want to
call the macro from an event, that means that you need to figure out how
to create a macro from a macro.
Download AndrewBase.odt and read the section titled "Dynamically call
object methods" The idea presented is as follows:
Create a library and a module, and then set the entire module text as a
string.
In your case, you would need to extract the string, and then modify the
string to create the subroutine that you desire.
What I would probably do, is create a method such as
Sub InsertTextAtCursor(s$)
' Insert the string s$ at the current view cursor
' Perhaps you accept another argument that indicates a paragraph style
to apply
End Sub
Then, the macro that you "create" would call InsertTextAtCursor and let
it do the heavy lifting This way, you can create a simpler macro.
If you want to create paragraph styles on the fly, I think that I at
least show how to create character styles in AndrewMacro.odt. I have
code that parses and color codes things such as Base, C++, Java, and
XML. AndrewMacro.odt demonstrates this (I have not added the XML code to
AndrewMacro.odt yet). The creation of character styles is demonstrated
there, however.
I know quite a bit is available through the API, but can I manage macros
through the API like this so one macro can define other macros and bind
them to keys?
Basically, I don't mind taking time to write the code ahead of time, but
it's critical to be able to set this up so my writing process is not
disturbed by having to click through menus or do anything else involved
when I set up macros.
I don't mind combing through API docs, but I want to be sure this can be
done before spending a long time searching for something that may not
be there.
Thanks for any help on this!
Hal
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info: http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]