Consulting

Results 1 to 6 of 6

Thread: Collapse and Expand

  1. #1
    VBAX Regular
    Joined
    May 2014
    Posts
    12
    Location

    Collapse and Expand

    Hi

    I'm trying to create a form with boxes and headings that the box collapses so everyone can see just the headings and expand individually the boxes to enter information in, then collapse after to just view headings.

    I used the code from wikihow, expand-and-collapse-in-microsoft-word, and it worked.

    However when I try and do it for the next box on my form it doesn't work. I get a compile error (see attached screen print)VBA screen print.docx

    Can anyone explain what I am doing wrong or a simpler method. I really know nothing about VBA.

    Thank you
    Shelley

  2. #2
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    The compile error is simple to fix. You can not have two subroutines with the same name. You have two named MYMACRO(). Rename one.

  3. #3
    VBAX Regular
    Joined
    May 2014
    Posts
    12
    Location
    Can I use any name? The MYMACRO was what wikihow gave me, So could I call them BOX1, BOX2 etc?

  4. #4
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Macros can have any name you want to give them, provided the name doesn't include invalid characters, isn't a duplicate or doesn't match certain reserved words, VBA properties, etc. (e.g. don't call a macro 'ActiveDocument'). The VBE will warn you or have a hissy-fit if you transgress these rules. Conversely, you can use names that match various built-in functions, so as to hijack them (e.g. FilePrint).
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  5. #5
    VBAX Regular
    Joined
    May 2014
    Posts
    12
    Location
    Thank you, it is working now, and I think I might just understand a little about what I am typing in!! Thanks for all your help.

  6. #6
    VBAX Regular
    Joined
    May 2014
    Posts
    12
    Location
    Sorry further issue if anyone can advise. It works on my computer, works on my colleagues computer, but for 3 other colleagues it doesn't work. They open up the document, select the form and it opens already expanded and the buttons to collapse the rows do not work. When they open the document they get asked to enable macros, which they do, but that makes no difference.

    Is this to do with their machine settings, or is it something I can fix?

    Thanks

Posting Permissions

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