Word VBA macro is now failing and I cannot determine what I did wrong

John Terdik 0 Reputation points

I recently posted this question at https://answers.microsoft.com/en-us/msoffice/forum/all/word-vba-macro-is-now-failing-2/34155b3d-d339-44a6-ad75-67a57576caa0 and it was suggested that I post my question in this area. Also, note that the previous mention posting was a repost of the question because the original question was locked.

A few years ago I found a macro that would make a backup copy of the Word MRU key, in Oct of 2022 it started to fail and I could not determine why. Because of other personal issues, I failed to respond to postings in the initial posting and the thread was lock.

Here is my latest posting regarding the failing macro.

The current macro is as follows

Sub AutoExec() 

' Create a backup of the File Mru registry key when word is opened. 

' MsgBox "Greetings", vbOKOnly, "Greetings" 

    Shell Environ("WINDIR") & "\SYSTEM32\reg.exe export " & Chr(34) & _ 

        "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\Word\User MRU\" & _ 

        "LiveId_1CAE3332AC58B37C7947B5C9B6B36B2BAD0F4B927087EB37A6DC5053FCF2A072\File MRU" & _ 

        Chr(34) & " C:\BackupFileMRU\Word-file-mru_" & Format(Now, "MM-dd-yyyy") & ".reg /Y" 

End Sub

I've checked the "LiveId_1CAE3332AC58B37C7947B5C9B6B36B2BAD0F4B927087EB37A6DC5053FCF2A072\File MRU" and it does have entries but this does not seem to be the source of the failure. At this time:

When I open word I see


Also, my AV reports the following

I attempted to determine why I'm getting the "Invalid procedure call or argument" but I don't know enough about VBA and so far my search has yielded numbers hits but nothing I understand.

Following is what I see in the register for the key. My assumption is that I should be able to export the values in the key and restore the key if it becomes damaged. This is what I was able to do until Oct 2022.

A family of Microsoft word processing software products for creating web, email, and print documents.
655 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,461 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. MotoX80 31,571 Reputation points

    This is not a VBA problem. You are getting that error because your antivirus software is blocking the call.

    User's image

    You can review the Bitdefender settings to see if there is some option that references Office macro's or sub-programs.

    Or contact Bitdefender support or ask the question in a Bitdefender specific forum.


    Your path of least resistance is probably to just create a bat file that contains the reg command and run that outside of Word.

    reg.exe export  "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\Word\User MRU\LiveId_1CAE3332AC58B37C7947B5C9B6B36B2BAD0F4B927087EB37A6DC5053FCF2A072\File MRU" "C:\BackupFileMRU\Word-file-mru_%date:~10,4%-%date:~4,2%-%date:~7,2%.reg" /Y 
    0 comments No comments

  2. John Terdik 0 Reputation points

    If I create a bat file I asume I could schedule a task to run the bat file daily. A daily run would be ok rather than running it every time I open Word.

    I did a bit of research and created the following as my BAT file

    set CUR_YYYY=%date:~10,4%

    set CUR_MM=%date:~4,2%

    set CUR_DD=%date:~7,2%


    reg.exe export "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\Word\User MRU\LiveId_D6CF29E4B97077D0A76F7336D24E2C0D2CC2C35617F8F98E36F6D833C8F7EF13\File MRU" "C:\BackupFileMRU\Word-file-mru_%SUBFILENAME%.reg" /Y

    Now when I execute the bat file in a CMD window (as admin) I now get this error:

    ERROR: Unable to write to the file. There may be a disk or file system error.

    So now I'm attempting to correct this error. I've found several postings but nothing I currently understand.

    OH JOY, the hole is getting bigger. At this time I trying to get the BAT file or the macro working, I don't care which as long as I can get one working.

    0 comments No comments

  3. John Terdik 0 Reputation points

    I just discovered that the DATE depends on what you have set in the Control Panel > Clock and Region > Region and here check the "Short Date". I selected MM/dd/yyyy now for the date I get 03/21/2023, then I had to change the parsing to the following

    set CUR_YYYY=%date:~6,4%

    set CUR_MM=%date:~0,2%

    set CUR_DD=%date:~3,2%


    This gave me 2023_0321 as my output.

    I'm not sure what the heck I did but the bat file is now working and I no longer get the error " Unable to write to the file. There may be a disk or file system error" I get "The operation completed successfully."

    Now to create a scheduled task, If I recall correctly I can set a trigger so when Word executes it will kick off the bat file.

    0 comments No comments

  4. John Terdik 0 Reputation points

    OK I just created a Task Schedule to run the BAT file every day at 2052 hours (the time I created the task. I could have picked any time that the PC would be running). I could not determine how to trigger the task when WORD started but once a day is good for me (I think). Thanks for the help! I was able to get a solution but for me it was an effort and more research. However, I'm happy at this time.

    0 comments No comments