+ Reply to Thread
Results 1 to 6 of 6

macro does not Run before Save

  1. #1
    Forum Contributor
    Join Date
    07-10-2020
    Location
    New Zealand
    MS-Off Ver
    365 personal
    Posts
    295

    macro does not Run before Save

    I have code (In This document) that I want to run each time eth Dc is saved. The code works when I run it manually but not when I save eth docm file.

    What do I need to do

    thanks

    Allister
    Attached Files Attached Files

  2. #2
    Banned User!
    Join Date
    01-17-2021
    Location
    Omaha, NE
    MS-Off Ver
    office 2016
    Posts
    211

    Re: macro does not Run before Save

    word does not have method called SaveAsHTMLBeforesave .

    this is what u need i think

    https://docs.microsoft.com/en-us/off...mentbeforesave

  3. #3
    Forum Contributor
    Join Date
    07-10-2020
    Location
    New Zealand
    MS-Off Ver
    365 personal
    Posts
    295

    Re: macro does not Run before Save

    I thought it worked but not yet - new file attached

    Does anyone know why ?

    Thanks
    Attached Files Attached Files
    Last edited by AllisterB; 03-02-2021 at 08:24 PM.

  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: macro does not Run before Save

    As you have already been told, there is no such event as SaveAsHtmBeforeSave in MS Word. And, even if it did have one, you have not initiated the event handler correctly. You don't even have 'Public WithEvents appWord As Word.Application' in the required Class Module.

    For the correct way to implement such events as Word does have, see: https://wordmvp.com/FAQs/MacrosVBA/AppClassEvents.htm. To the extent it's relevant, you need to employ Word's DocumentBeforeSave event - which you cannot simply rename.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  5. #5
    Forum Contributor
    Join Date
    07-10-2020
    Location
    New Zealand
    MS-Off Ver
    365 personal
    Posts
    295
    Thank you for the article.
    It refers to place a file in words startup directory. If I do this will it work for other people I distribute it too if they are on separate systems from mine?

  6. #6
    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: macro does not Run before Save

    Quote Originally Posted by AllisterB View Post
    It refers to place a file in words startup directory. If I do this will it work for other people I distribute it too if they are on separate systems from mine?
    Yes, provided they do likewise.

+ 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. 1 macro to Save as w file name + progressive number & another save as for next data entry
    By ILoveStMartin in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-08-2019, 06:38 PM
  2. [SOLVED] Disable SAVE, SAVE AS & CTRL+S once Macro is executed
    By RIZVI in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-11-2019, 08:24 AM
  3. Excel Macro - to move selected sheets no a new workbook and save, and save as pdf
    By manekankit in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2019, 01:42 PM
  4. [SOLVED] Need to loop a macro to save images to file - but save to user defined directory.
    By superfurry in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-19-2015, 07:49 AM
  5. Macro to Auto save a backup copy in a seperate location OR save file with a pop up
    By kdsanderson30 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-12-2014, 12:38 PM
  6. Macro with cell reference as a name, but prompt for save location and save as csv
    By tomham in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-15-2012, 06:21 PM
  7. where can i find macro codes for various functions such print, save and save as
    By fellayaboy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-23-2011, 02:06 AM

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