Page 1 of 2 12 LastLast
Results 1 to 15 of 30
  1. #1
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Belle Harbor, New York, USA
    Posts
    256
    Thanks
    0
    Thanked 0 Times in 0 Posts

    macros for macron (Word 2003)

    For the past several days I have been working on a project involving creating macros to put the macrons (small horizontal lines) on vowels in Latin. I have been successful in creating macros for all ten (small and capital) vowels. (For example, a macro was created that permitted me to type Alt+S,A to put a macron on a small a).
    However, I have just noticed something peculiar: If the vowel is within the word the macro does not work. The macro does work if the vowel stands alone, a situation that will never be.
    I have also noticed that instead of running a macro, I can use the following procedure: Insert>symbol>highlight symbol>click on Shortcut
    Key>Type shortcut key in box that says "Press new shortcut key">Assign>Close>Close.
    The question that remains is, "Why is it that the macro works only when the letter stands alone and not within the word? (Same situation when I attempt to run the macro. Tools>Macro>Macros>Select macro>Run)
    Thank you very much and also, thank you to Hans for his assistance a few days ago.
    Alan Silberlight

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: macros for macron (Word 2003)

    Can you post the VBA code from your Macro, it is very hard to guess without seeing the code.

    StuartR

  3. #3
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Belle Harbor, New York, USA
    Posts
    256
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: macros for macron (Word 2003)

    Thank you for responding so quickly. I don't know how to post the VBA code. Can I send you a copy of the Normal template? Would that help? Thank you.

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: macros for macron (Word 2003)

    Alan (or is it Chris),

    How did you create the code? Assuming that you recorded the macro then the easiest way to get a copy is to...
    <UL><LI>Type Alt-F11 when running Word, this will take you to the Visual Basic Environment (VBE).
    <LI>In the Project window at the top left, expand Normal, then expand Modules and double click NewMacros (or any other module that you find)
    <LI>The code should appear in the main code window, use your mouse to select and copy all of this code
    <LI>Paste the code into a post here in the lounge
    <LI>Put <!t>[PRE]<!/t> before your code and <!t>[/PRE]<!/t> after your code to tell the lounge software that this is "preformatted" text that it should leave alone[/list]StuartR

  5. #5
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Belle Harbor, New York, USA
    Posts
    256
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: macros for macron (Word 2003)

    It's Alan. Ok...I hope I do this right

    <pre>Sub macronsmalla()
    '
    ' macronsmalla Macro
    ' Macro recorded 1/25/2005 by Alan Silberlight
    '
    Selection.TypeText Text:="0101"
    Selection.ToggleCharacterCode
    End Sub
    Sub macronsmalle()
    '
    ' macronsmalle Macro
    ' Macro recorded 1/25/2005 by Alan Silberlight
    '
    Selection.TypeText Text:="0113"
    Selection.ToggleCharacterCode
    End Sub
    Sub macronsmalli()
    '
    ' macronsmalli Macro
    ' Macro recorded 1/26/2005 by Alan Silberlight
    '
    Selection.TypeText Text:="012B"
    Selection.ToggleCharacterCode
    End Sub
    Sub macronsmallo()
    '
    ' macronsmallo Macro
    ' Macro recorded 1/26/2005 by Alan Silberlight
    '
    Selection.TypeText Text:="014D"
    Selection.ToggleCharacterCode
    End Sub
    Sub macronsmallu()
    '
    ' macronsmallu Macro
    ' Macro recorded 1/26/2005 by Alan Silberlight
    '
    Selection.TypeText Text:="016B"
    Selection.ToggleCharacterCode
    End Sub
    Sub macroncapA()
    '
    ' macroncapA Macro
    ' Macro recorded 1/26/2005 by Alan Silberlight
    '
    Selection.TypeText Text:="0100"
    Selection.ToggleCharacterCode
    End Sub
    Sub macroncapE()
    '
    ' macroncapE Macro
    ' Macro recorded 1/26/2005 by Alan Silberlight
    '
    Selection.TypeText Text:="0112"
    Selection.ToggleCharacterCode
    End Sub
    Sub macroncapI()
    '
    ' macroncapI Macro
    ' Macro recorded 1/26/2005 by Alan Silberlight
    '
    Selection.TypeText Text:="012A"
    Selection.ToggleCharacterCode
    End Sub
    Sub macroncapO()
    '
    ' macroncapO Macro
    ' Macro recorded 1/26/2005 by Alan Silberlight
    '
    Selection.TypeText Text:="014C"
    Selection.ToggleCharacterCode
    End Sub
    Sub macroncapU()
    '
    ' macroncapU Macro
    ' Macro recorded 1/26/2005 by Alan Silberlight
    '
    Selection.TypeText Text:="016A"
    Selection.ToggleCharacterCode
    End Sub</pre>


  6. #6
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: macros for macron (Word 2003)

    Alan,

    The problem with your code is that ToggleCharacterCode expects the word where your selection is to be a hex character code. That is why it doesn't works if it inserts the hex code into an existing word.

    Try this code instead, just delete all your current macros and paste these in instead.

    StuartR
    <code>
    Sub macronsmalla()
    Selection.InsertBefore (ChrW(257))
    End Sub
    Sub macronsmalle()
    Selection.InsertBefore (ChrW(275))
    End Sub
    Sub macronsmalli()
    Selection.InsertBefore (ChrW(299))
    End Sub
    Sub macronsmallo()
    Selection.InsertBefore (ChrW(333))
    End Sub
    Sub macronsmallu()
    Selection.InsertBefore (ChrW(363))
    End Sub
    Sub macroncapA()
    Selection.InsertBefore (ChrW(256))
    End Sub
    Sub macroncapE()
    Selection.InsertBefore (ChrW(274))
    End Sub
    Sub macroncapI()
    Selection.InsertBefore (ChrW(298))
    End Sub
    Sub macroncapO()
    Selection.InsertBefore (ChrW(332))
    End Sub
    Sub macroncapU()
    Selection.InsertBefore (ChrW(362))
    End Sub
    </code>

  7. #7
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Belle Harbor, New York, USA
    Posts
    256
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: macros for macron (Word 2003)

    Wow...you are good!!! It worked. What mistake did I make when I was creating the macro? What should I have done? Also, can I paste this into Word in another computer? I tried it, without success. Thank you.

  8. #8
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: macros for macron (Word 2003)

    You were a bit unlucky. The Macro recorder is often good enough, but nothing beats looking in the object model and choosing the commands that do exactly what you want. I just tried recording the code to insert a symbol and the Macro recorder generated code that looks like:
    <code> Selection.InsertSymbol Font:="Times New Roman", CharacterNumber:=228, Unicode:=True</code>

    which would have worked if you'd done it that way (but would probably be improved by removing the <code>Font="Times New Roman"</code>
    )

    This code should work fine when you copy it into someone else's PC, it worked when we copied it from my PC to yours. How are you copying it? Do they already have the previous version of your Macros in a different module? If so then you may need to delete the old ones.

    StuartR

    Edited to add... It's 01:07 here in the UK and I'm off to bed now, hopefully someone else will respond to any more questions you have tonight. Good night.

  9. #9
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Belle Harbor, New York, USA
    Posts
    256
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: macros for macron (Word 2003)

    Again, thank you. I have tried to apply this same code to another computer running Word 2002 on an ME machine. No luck. I would like to bring this code to school to help the Latin teachers. Most of the machines are running Word 2000.
    Alan

  10. #10
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: macros for macron (Word 2003)

    Sorry, I no longer have a copy of Word 2000 to test this on, maybe another lounger can test the code.

    StuartR

  11. #11
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    120
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: macros for macron (Word 2003)

    I've pasted Stuart's code into a new project in Word 2000 and the macron insertion appears to work a treat so you should have no problem providing it for the Latin teachers

  12. #12
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Belle Harbor, New York, USA
    Posts
    256
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: macros for macron (Word 2003)

    Thank you. I have tried to apply Stuart's code to my other computer, running Word 2002. It does not work. I'm sure that I'm doing something incorrectly. Can you tell me what steps I must take? Thank you very much.
    Alan Silberlight

  13. #13
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: macros for macron (Word 2003)

    When you say it does not work, what do you mean? What do you do, and what happens when you do it. Do you get an error message, if so what is it?

    One possibility. Your original post indicated that you were using shortcut keys to run the macros. After putting the code into Normal.dot on your other computer, did you reassign the shotcut keys to the macros?
    Legare Coleman

  14. #14
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Belle Harbor, New York, USA
    Posts
    256
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: macros for macron (Word 2003)

    On the other computer I pressed Alt+F11, clicked on Modules in the Project-Normal window, clicked on New Macros, and pasted Stuart's code on the right side. When I type Alt+C, I get a window called Com Add ins. When I type Alt+S, I get a window that says Show Comments, Inserts and Deletions, Formatting, Reviews, Reviewing Pane, Options. Could it be that Alt+S and Alt+C have other functions on this computer? I don't know. In a few hours, I'm going to paste Stuart's code onto a school computer running Word 2000 and Windows ME. I will let you know what happens.
    I am still left with the following question: Why did my original macros produce a situation where they would not work if the vowel was in the middle of the word? Stuart recognized the problem immediately. What mistake did I make in creating the macro? As you probably have realized, I do not have a knowledge of Visual Basic.
    Thank you very much for taking the time to help me. I do appreciate it.

  15. #15
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: macros for macron (Word 2003)

    When you copy a macro from one PC/user to another, you don't copy the keyboard shortcut with it. You must either set the keyboard shortcuts on the target PC/user, or store the macros and their keyboard shortcuts in a template, and install that as a global template for the target PC/user.

    As Stuart already pointed out, the macro recorder is not perfect. In some cases, recorded code will not work correctly (or not at all). That's when you will have to edit the macros manually.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •