+ Reply to Thread
Results 1 to 5 of 5

Can't Record Macro which changes formatting

  1. #1
    Registered User
    Join Date
    10-23-2017
    Location
    NS, CA
    MS-Off Ver
    2016
    Posts
    17

    Can't Record Macro which changes formatting

    Hi

    I am working with Word 2016. I am trying to use the macro recorder to record a macro which removes the header, footer, and water mark from the first page of a document. The problem is the recorder is not recording any of the steps i take to do that! I end up with a blank macro.

    I did check to make sure I had macros enabled in the trust center and I do.

    Is there anything obvious I am missing which will fix this issue? And if not, can someone give me some pointers on writing a macro to do the above and the reverse of the above (adding a header, footer, and watermark to the first page). This is my first time working with Macros in Word (I have worked with them in Excel and Outlook).

    Thanks,

    Allison

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Can't Record Macro which changes formatting

    The simple answer is that the macro recorder doesn't record everything you can do through the GUI. In any event, unless your document is configured with either a 'different first page' layout or has a Section break between the first & second pages, with the second Section's header & footer unlinked from the first Section, what you're trying to do would affect every page. Provided those conditions are satisfied, you could use a macro like:
    Please Login or Register  to view this content.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Registered User
    Join Date
    10-23-2017
    Location
    NS, CA
    MS-Off Ver
    2016
    Posts
    17

    Re: Can't Record Macro which changes formatting

    Well that is just silly to have a recorder which isn't set up to record everything..... Kind of defeats the purpose. Anyway thank you very much for this, it is set up as a different first page layout and does exactly what I need it to.

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Can't Record Macro which changes formatting

    Quote Originally Posted by AllisonNS View Post
    Well that is just silly to have a recorder which isn't set up to record everything..... Kind of defeats the purpose.
    The macro recorder can record your actions in this case. I don't know what you did that meant nothing was recorded.

    That said, the macro recorder can't record everything in Excel, either, so I'm surprised you didn't know its limitations already. Moreover, no matter which application you're using, the macro recorder is as dumb as a box of rocks: it records a lot of irrelevant stuff; records actions using Activate, Select, etc., which are very inefficient. It's completely clueless about loops and a whole bunch of other stuff. FWIW, this is the code I get using the macro recorder:
    Please Login or Register  to view this content.
    Aside from all the unnecessary stuff it's recorded, it would only work correctly if your insertion point was on the first page; run it from anywhere else and it'll wipe out your header/footer there, instead. It also forces your display into PrintView display mode regardless of what mode you're working in. The code I wrote can be run from anywhere, will only affect the header/footer that appears on the first page, and Doesn't alter your display mode. Knowing now that you have a 'different first page' setup, could be reduced to:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-23-2017
    Location
    NS, CA
    MS-Off Ver
    2016
    Posts
    17

    Re: Can't Record Macro which changes formatting

    I don't know what was going on but every time i went through those actions all I got was a blank macro with a sub, few blank lines, and an end sub.
    I do know there are some limitations to excel's macro recorder but usually if it is something I can record doing some of, I will start by doing that then go in and add the parts I can't record and tidy up what was recorded. I find it noce to have a starting point instead of writing out everything.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Create a user button to record a formatting macro
    By Groovicles in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-29-2016, 03:55 PM
  2. simple macro to add new record, edit/ search and print record
    By xmoore in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-28-2015, 08:10 PM
  3. Record Macro with IF statements from conditional formatting.
    By ja489 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-20-2013, 02:43 PM
  4. [SOLVED] Record Macro function does not record certain commands
    By m185945 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 11-01-2013, 11:02 AM
  5. Replies: 1
    Last Post: 11-16-2012, 09:25 AM
  6. Macro add new record without replacing or affecting old record
    By Kenji in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-23-2010, 01:56 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1