locked
Macro to insert section break and format columns would be nice, but it doesn't work... RRS feed

  • Question

  • I am using Word 2007.

    I have recorded a macro to do the following:

    - insert continuous section break

    - format the new section for 3 columns

    - insert another continuous section break

    - format the new section for 1 column

    When I run the macro the system displays a 'Run-time error 5138'.

    When I click Debug the following line is highlighted in the code:

            .Width = CentimetersToPoints(15.92)

    Not sure what the problem is here - unfortunately I do not know visual basic.


    • Edited by nivlektech Tuesday, October 2, 2012 1:03 PM spelling mistake
    Tuesday, October 2, 2012 1:02 PM

Answers

  • Just delete that line! When you do you'll probably find you get the same error on another copy of that line further down in the code - delete that one too.
     
    The macro recorder is not perfect and sometimes records things that don't need, or want, to be done. Sometimes it also misses out things that do need to be done, which can be harder to fix.
     

    Enjoy,
    Tony
    www.WordArticles.com
    • Marked as answer by Max Meng Monday, October 8, 2012 5:11 AM
    Wednesday, October 3, 2012 12:16 PM
  • Is there a way that I can copy this macro and store it within a specific file? At the moment the macro only works on the PC which was used to record the macro.

    Yes, there is.

    To do so, create a Word Macro-Enabled Template file (.dotm) to store your macro and save it in a network shared folder.

    Set the network shared folder as the Word Startup folder for the other client. We can modify the setting either through GPO or manually: Word Options | Advanced | File Location | Startup

    Sincerely,

    Max Meng
    Forum Support


    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please contact tnmff@microsoft.com.

    • Edited by Max Meng Monday, October 8, 2012 5:50 AM
    • Marked as answer by nivlektech Wednesday, October 10, 2012 9:09 PM
    Monday, October 8, 2012 5:49 AM

All replies

  • Show us more of the code, in particular, so that we can tell what Width is set...

    Stefan Blom, Microsoft Word MVP
    Tuesday, October 2, 2012 6:46 PM
  • Just delete that line! When you do you'll probably find you get the same error on another copy of that line further down in the code - delete that one too.
     
    The macro recorder is not perfect and sometimes records things that don't need, or want, to be done. Sometimes it also misses out things that do need to be done, which can be harder to fix.
     

    Enjoy,
    Tony
    www.WordArticles.com
    • Marked as answer by Max Meng Monday, October 8, 2012 5:11 AM
    Wednesday, October 3, 2012 12:16 PM
  • Yes, that worked thanks.

    Is there a way that I can copy this macro and store it within a specific file? At the moment the macro only works on the PC which was used to record the macro.

    Wednesday, October 3, 2012 3:41 PM
  • Is there a way that I can copy this macro and store it within a specific file? At the moment the macro only works on the PC which was used to record the macro.

    Yes, there is.

    To do so, create a Word Macro-Enabled Template file (.dotm) to store your macro and save it in a network shared folder.

    Set the network shared folder as the Word Startup folder for the other client. We can modify the setting either through GPO or manually: Word Options | Advanced | File Location | Startup

    Sincerely,

    Max Meng
    Forum Support


    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please contact tnmff@microsoft.com.

    • Edited by Max Meng Monday, October 8, 2012 5:50 AM
    • Marked as answer by nivlektech Wednesday, October 10, 2012 9:09 PM
    Monday, October 8, 2012 5:49 AM
  • "Tony Jollans [MVP]" wrote in message news:51af1d01-930a-4c0d-a437-4b68c9d1f18a@communitybridge.codeplex.com...
    Just delete that line! [---]

     
    Simple and obvious fix, I guess. :-)

    Stefan Blom, Microsoft Word MVP
    Monday, October 8, 2012 5:33 PM