Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-16-2016, 04:13 PM
dan88 dan88 is offline Word Template - Userform launch from QAT giving error "Wrong number of Arguments" Windows 10 Word Template - Userform launch from QAT giving error "Wrong number of Arguments" Office 2016
Novice
Word Template - Userform launch from QAT giving error "Wrong number of Arguments"
 
Join Date: Feb 2016
Posts: 24
dan88 is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 05-16-2016, 08:38 PM
Guessed's Avatar
Guessed Guessed is offline Word Template - Userform launch from QAT giving error "Wrong number of Arguments" Windows 10 Word Template - Userform launch from QAT giving error "Wrong number of Arguments" Office 2013
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #3  
Old 05-17-2016, 04:56 AM
dan88 dan88 is offline Word Template - Userform launch from QAT giving error "Wrong number of Arguments" Windows 10 Word Template - Userform launch from QAT giving error "Wrong number of Arguments" Office 2016
Novice
Word Template - Userform launch from QAT giving error "Wrong number of Arguments"
 
Join Date: Feb 2016
Posts: 24
dan88 is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post

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?
.
Hello Andrew,

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
Reply With Quote
  #4  
Old 05-17-2016, 05:00 AM
dan88 dan88 is offline Word Template - Userform launch from QAT giving error "Wrong number of Arguments" Windows 10 Word Template - Userform launch from QAT giving error "Wrong number of Arguments" Office 2016
Novice
Word Template - Userform launch from QAT giving error "Wrong number of Arguments"
 
Join Date: Feb 2016
Posts: 24
dan88 is on a distinguished road
Default

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>
I then right clicked on this button to show on the QAT.

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
dan
Reply With Quote
  #5  
Old 05-17-2016, 06:02 AM
Charles Kenyon Charles Kenyon is offline Word Template - Userform launch from QAT giving error &quot;Wrong number of Arguments&quot; Windows 8 Word Template - Userform launch from QAT giving error &quot;Wrong number of Arguments&quot; Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,081
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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.
Reply With Quote
  #6  
Old 05-17-2016, 09:26 AM
dan88 dan88 is offline Word Template - Userform launch from QAT giving error &quot;Wrong number of Arguments&quot; Windows 10 Word Template - Userform launch from QAT giving error &quot;Wrong number of Arguments&quot; Office 2016
Novice
Word Template - Userform launch from QAT giving error &quot;Wrong number of Arguments&quot;
 
Join Date: Feb 2016
Posts: 24
dan88 is on a distinguished road
Default

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
Now I have a suspicion that it clashed with another userform I had in Normal Template.

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
Reply With Quote
  #7  
Old 05-17-2016, 10:03 AM
Charles Kenyon Charles Kenyon is offline Word Template - Userform launch from QAT giving error &quot;Wrong number of Arguments&quot; Windows 8 Word Template - Userform launch from QAT giving error &quot;Wrong number of Arguments&quot; Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,081
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word Template - Userform launch from QAT giving error &quot;Wrong number of Arguments&quot; 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

Other Forums: Access Forums

All times are GMT -7. The time now is 09:54 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft