|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Word Template - Userform launch from QAT giving error "Wrong number of Arguments"
Hi,
I created a userform that has a few macros on it I added a button on the QAT to run this form - This works perfectly. This file is a DOCM. Next I want this userform and its macros to be available to all documents. I saved the files as a.DOTM and put it in start up folder. When I open a normal document - the icons show on the QAT - the way I designed it. However when i click the button is says wrong number of arguments. I am not sure what I have done wrong? I cant find the answer and have spent hours please advice many thanks dan Last edited by Charles Kenyon; 05-17-2016 at 12:29 PM. Reason: changed title to give better info about problem |
#2
|
||||
|
||||
Wrong number of arguments error sounds like it is trying to run a function without supplying the input values that are required by that function.
Does the DOTM template work when it is opened directly? Were the buttons in the QAT added via a ribbon editor or via the GUI? Perhaps you need to post your template so we can have a look at what has gone wrong.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
Quote:
the DOTM works when i open it, that is the form appears when i press the QAT button The buttons where added using a ribbon editor - The custom UI editor dan |
#4
|
|||
|
|||
Code:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"> <ribbon> <tabs> <tab id="UserForm" label="Userform" > <group id="customGroup" label="Custom Group" visible="false" > <button id="Btn1" label="UserForm" image="UserForm" onAction="ShowForm"/> <button id="Btn2" label="Hide User Form" image="Hide" onAction="HideForm"/> </group> in a module i have this Code:
Sub ShowForm(control As IRibbonControl) iUserForm1.Show vbModeless End Sub Sub HideForm(control As IRibbonControl) iUserForm1.Hide end sub |
#5
|
|||
|
|||
Try removing "control as IRibbonControl" from your vba. That does not work on QAT icons but only on Ribbon buttons.
I ran into the obverse problem a while back where it would run from a button on the QAT or by calling the macro directly when the template was loaded as a global but would not run from the ribbon button. See Wrong number of arguments or invalid property assignment error message in Ribbon customization By the way, I find using the UI as the principle way to modify the QAT easier than xml. Then I may modify the XML to add tooltips and supertips or change the icon. |
#6
|
|||
|
|||
Hi Charles,
been fiddling and tweaking and this code works Code:
Sub ShowForm1(control As IRibbonControl) iUserForm1.Show vbModeless End Sub Sub HideForm1(control As IRibbonControl) iUserForm1.Hide End Sub The macros for showing the form were the same - as it was in a different template i thought this would be ok They were both named Sub ShowForm() Sub HideForm() So for the iUserform I renamed it to Sub ShowForm1() Sub Hideform1() it seems to be picking up the user form now. Let me do some more testing..but i am on the right track i think thanks dan |
#7
|
|||
|
|||
When you have multiple macros with the same name in different templates, see The Hierarchy of Templates in Microsoft Word.
Those in the document run before those in the attached templates which run before those in the normal template which run before those in other global templates. I suspect but do not know that when you have the same macro in multiple global templates, the macro in the first template loaded will run, but I do not know that. Consider giving more explicit names or including the project name in the name called. Last edited by Charles Kenyon; 05-17-2016 at 12:31 PM. |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Agenda template - userform | kennyD | Word | 4 | 04-07-2015 01:32 PM |
userform to enter multiple lines of data in template | callasabra | Word VBA | 0 | 06-27-2014 05:29 PM |
5941 requested member of collection does not exist Prevents Userform from Showing | marksm33 | Word VBA | 1 | 02-22-2014 08:56 AM |
showing a userform after hiding | jillapass | Word VBA | 0 | 05-31-2012 06:13 AM |
How to get Outlook 2007 userform into template? | Royzer | Outlook | 0 | 04-13-2012 10:41 AM |