+ Reply to Thread
Results 1 to 8 of 8

Help with Programming of Macro for Batch Header/Footer/Body Text Change

  1. #1
    Registered User
    Join Date
    04-03-2014
    Location
    Walnut Creek, CA
    MS-Off Ver
    2013
    Posts
    15

    Question Help with Programming of Macro for Batch Header/Footer/Body Text Change

    I acquired this macro - I think I got it on this website, I can't really remember - anyway, it works at the task of changing the text in a header on multiple documents...for the most part. It's pretty hit or miss. I'd run it and it worked for about 10 of the 36 documents in a folder, so I tried it again and it worked on couple more, but then left a bunch unchanged. I basically started moving them to another folder one at a time and retrying the macro and it got to a point where it would seem to run but not change anything. In the end 6 documents would inexplicably not work with the macro even though I have run this macro on these 36 documents a week or two ago and it worked with no issues.

    I don't really understand much of the code, I was hoping this would be more black and white, but the infrequency of the macro working tells me there is something of a gray area - can someone take a look at this and tell me if you can see where the issue is? Is it possible that my computer ran out of memory when executing the macro? The work laptops they give us have nothing special as far as CPUs go or what they put under the hood.

    This is the Macro:

    Please Login or Register  to view this content.

  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: Help with Programming of Macro for Batch Header/Footer/Body Text Change

    This issue isn't the macro but, most likely, that you're running it from the same folder that you're trying to update. When you do that, the macro processes its own document, the closes it, which terminates the process.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Registered User
    Join Date
    04-03-2014
    Location
    Walnut Creek, CA
    MS-Off Ver
    2013
    Posts
    15

    Re: Help with Programming of Macro for Batch Header/Footer/Body Text Change

    Hmmm I see - I was indeed running the macro from a file in a separate folder. The folder was on a shared drive and the folder with the documents I was batch processing was on my desktop. Perhaps I should try using the macro file from my C: drive instead of the shared drive.

  4. #4
    Registered User
    Join Date
    04-03-2014
    Location
    Walnut Creek, CA
    MS-Off Ver
    2013
    Posts
    15

    Re: Help with Programming of Macro for Batch Header/Footer/Body Text Change

    So I ran it from two separate folders, one was on my desktop with the 36 policies I wanted to batch update. The other folder was a generic 'New Folder' within the 'Windows' folder that contained the macro-enabled word file with the macro above. I ran the macro and selected the folder on my desktop containing the policies and upon watching it work, I saw the 'date modified' start to change on the policy files, however, it got hung up at the 12th document and stopped. I looked at the files afterwards and the ones that updated did so properly but then the ones remaining after #12 were unchanged. Any ideas?

    The word files are more or less the same format the only difference being the content - the element I wanted to change was in the header, it was a standard sentence of text across all 36 that I need to update.

  5. #5
    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: Help with Programming of Macro for Batch Header/Footer/Body Text Change

    There's a number of possibilities, including documents that are protected, read-only, have macros of their own and/or are mailmerge main documents. Unless you can say what is different about the documents it doesn't work on, I can't really be more specific. As coded, though, the document will work on any folder of generic documents - without crashing.

    You've evidently also modified the code, to delete content from this loop, which you no longer need:
    Please Login or Register  to view this content.
    And, since you only want to process the headers, you may as well delete this code too:
    Please Login or Register  to view this content.
    The only other thing I can suggest at this stage is that you try adding:
    DoEvents
    after:
    .Close SaveChanges:=True
    That will give Word a bit more time for its own housekeeping between documents.

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Help with Programming of Macro for Batch Header/Footer/Body Text Change

    Quote Originally Posted by Haroon525 View Post
    I have also a problem with this.
    @Haroon525

    It has been noticed that your recent postings in this and other threads don't add anything to the information being sought. Please only post if you have something relevant to say.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  7. #7
    Registered User
    Join Date
    04-03-2014
    Location
    Walnut Creek, CA
    MS-Off Ver
    2013
    Posts
    15

    Re: Help with Programming of Macro for Batch Header/Footer/Body Text Change

    Still no luck with this one, it works on about 5 documents and then gives up - I am attaching it here if you want to take a stab at it again. Could you post the original macro code?

    Please Login or Register  to view this content.

  8. #8
    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: Help with Programming of Macro for Batch Header/Footer/Body Text Change

    There is no problem, as such with the macro. If it's not processing all files, that suggests there is something else going on in your system that interferes with the process. That could be a third-party Word addin or even a completely unrelated background process running on your system.

+ 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. Change Header or footer using input box
    By hecgroups in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-07-2016, 02:51 PM
  2. Macro to change the dates in header & footer for all Word documents
    By olga6542 in forum Word Programming / VBA / Macros
    Replies: 1
    Last Post: 09-13-2010, 05:39 PM
  3. Macro to change the dates in header & footer for all Word documents
    By olga6542 in forum Word Programming / VBA / Macros
    Replies: 2
    Last Post: 09-13-2010, 03:07 PM
  4. change color on header and footer
    By associates in forum Excel General
    Replies: 1
    Last Post: 09-16-2008, 01:47 AM
  5. [SOLVED] Programming header/footer strings with line feed
    By XP in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-26-2005, 09:05 AM

Tags for this Thread

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