locked
Saving document from custom ribbon - "Wrong number of arguments" message RRS feed

  • Question

  • Hi all.

     

    I have created a custom ribbon for Office 2010 and 2007 for internal company use.  I created it all in a standard .docm document initially, to work out any issues. There are a number of different macros that are run from custom buttons, including 2 very simple ones:

    • Save the document
    • Run a spellcheck

    Once everything was working, I emptied the contents of my document and renamed it to a .dotm file. I then copied it into my Word 2010 Startup folder. Now, I open a Word document and my new menu options appear with all my buttons.

    I click on my Save button and the following error appears:

    Wrong number of arguments or invalid property assignment

    I click on the spellcheck button and it works OK.

    The code for save is ridiculously simple:

     

    Sub SaveDoc
    
    activedocument.save
    
    End sub

     

     The code for the spellcheck is likewise simple:

     

    Sub spellchDoc
    
    activedocument.spellcheck
    
    End sub

     

    I cannot understand why the save is not working. To confuse things even more, I have put the same file in a Word 2007 Startup folder, on a different machine, and the save works fine on that!!

    Any ideas would be greatly appreciated.

    Tuesday, May 17, 2011 9:41 AM

Answers

  • Solved it myself!!!

    I realised that I already had the Save macro in my Normal.dot, with the same name, so I assume Word did not know which one to open and gave me the error. Renamed my own macros and all OK now. 

    • Marked as answer by D.R.Howells Thursday, May 19, 2011 9:06 AM
    Thursday, May 19, 2011 9:06 AM

All replies

  • Hi 

     

    Thank you for using Microsoft Office for IT Professionals Forums.

     

    I have copy your code & follow your describe to save work fine.

    This problem may occur Windows system file(E.X: vbscript.dll,jscript.dll)  was missing or was corrupted.

     

    Use the System File Checker tool (SFC.exe) to determine which file is causing the issue, and then replace the file. To do this, follow these steps:

    1. Open an elevated command prompt. To do this, click Start, click All Programs, click Accessories, right-click Command Prompt, and then click Run as administrator. If you are prompted for an administrator password or for a confirmation, type the password, or click Allow.
    2. Type the following command, and then press ENTER:

    sfc /scannow 

    The sfc /scannow command scans all protected system files and replaces incorrect versions with correct Microsoft versions.

     

    More detailed information you can refer to this Knowledge article:

    How to use the System File Checker tool to troubleshoot missing or corrupted system files on Windows Vista or on Windows 7

    http://support.microsoft.com/kb/929833

     

    If the System File Checker tool cannot repair a file, follow these steps:

    1. At an elevated command prompt, type the following command, and then press ENTER:
                         takeown /f Path_And_File_Name

      For example, type takeown /f E:\windows\system32\jscript.dll.

    2. Type the following command, and then press ENTER to grant administrators full access to the file:

      icacls Path_And_File_Name /GRANT ADMINISTRATORS:F

      For example, type icacls E:\windows\system32\jscript.dll /grant administrators:F.

    3. Type the following command to replace the file with a known good copy of the file:

      Copy Path_And_File_Name_Of_Source_FilePath_And_File_Name_Of_Destination

      For example, type copy E:\temp\jscript.dll E:\windows\system32\jscript.dll.

     

    Please take your time to try the suggestions and let me know the results at your earliest convenience. If anything is unclear or if there is anything I can do for you, please feel free to let me know.

     

    Hope that helps.

     

    Sincerely

    William Zhou CHN
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
     


    Thursday, May 19, 2011 2:37 AM
  • Hi and thanks for the reply....

    I did try the above but no problems were found.

    I should also add the following... When my template is in the Word STARTUP folder, the Save macro will not work. If I move it out of this folder and open it, the macro works fine! I really am at a loss.

    Thursday, May 19, 2011 8:33 AM
  • Solved it myself!!!

    I realised that I already had the Save macro in my Normal.dot, with the same name, so I assume Word did not know which one to open and gave me the error. Renamed my own macros and all OK now. 

    • Marked as answer by D.R.Howells Thursday, May 19, 2011 9:06 AM
    Thursday, May 19, 2011 9:06 AM