Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2005

Tip: Looking for answers? Try searching our database.

Max number of args to a function?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rick Charnes - 18 Oct 2005 16:54 GMT
Is there a limit to the number of arguments a VBA function can take in
Word 2003?  Someone mentioned two or three years ago that the limit was
59, but I am wondering if that has changed.  I don't see anything in
Help about this.  Thanks.
Tony Jollans - 18 Oct 2005 18:31 GMT
Close! 60.

--
Enjoy,
Tony

> Is there a limit to the number of arguments a VBA function can take in
> Word 2003?  Someone mentioned two or three years ago that the limit was
> 59, but I am wondering if that has changed.  I don't see anything in
> Help about this.  Thanks.
Rick Charnes - 18 Oct 2005 18:44 GMT
Thanks.  Where would I have found this figure?  Don't see it anywhere in
Help.

> Close! 60.
>
[quoted text clipped - 6 lines]
> > 59, but I am wondering if that has changed.  I don't see anything in
> > Help about this.  Thanks.
Tony Jollans - 18 Oct 2005 20:35 GMT
To be honest, I don't know - a quick look at help turned up nothing.

I had a feeling it was 60 and it only took a moment to try and use 61 and
find it didn't work.

--
Enjoy,
Tony

> Thanks.  Where would I have found this figure?  Don't see it anywhere in
> Help.
[quoted text clipped - 9 lines]
> > > 59, but I am wondering if that has changed.  I don't see anything in
> > > Help about this.  Thanks.
Jezebel - 18 Oct 2005 22:10 GMT
You can use a  ParamArray to send an arbitrary number of arguments.

> To be honest, I don't know - a quick look at help turned up nothing.
>
[quoted text clipped - 23 lines]
>> > > 59, but I am wondering if that has changed.  I don't see anything in
>> > > Help about this.  Thanks.
Tony Jollans - 18 Oct 2005 22:51 GMT
Technically it's one argument that the procedure receives but, yes, the
number of elements is, AFAIK, unlimited (or, I suppose, limited only by the
maximum length of the calling statement).

--
Enjoy,
Tony

> You can use a  ParamArray to send an arbitrary number of arguments.
>
[quoted text clipped - 25 lines]
> >> > > 59, but I am wondering if that has changed.  I don't see anything in
> >> > > Help about this.  Thanks.
Rick Charnes - 19 Oct 2005 16:18 GMT
I'm actually calling this Word macro from another application
(Powerbuilder) which installs Word as an OLE server and therefore allows
me to send commands to Word such as 'execute this macro'.  Currently, I
call the macro from Powerbuilder with about 12 arguments and it works
great.  I'd now like to add about 80 more (I know it sounds crazy...)

Tony, you mention that the number of elements is unlimited but you got
an error at 61?  Maybe as you suggest the limit is the length of the
calling statement rather than the number of elements?

> Technically it's one argument that the procedure receives but, yes, the
> number of elements is, AFAIK, unlimited (or, I suppose, limited only by the
[quoted text clipped - 3 lines]
> Enjoy,
> Tony
Jezebel - 19 Oct 2005 22:14 GMT
Put your arguments into an array, and pass that as a single argument.

> I'm actually calling this Word macro from another application
> (Powerbuilder) which installs Word as an OLE server and therefore allows
[quoted text clipped - 14 lines]
>> Enjoy,
>> Tony
Rick Charnes - 20 Oct 2005 16:50 GMT
Thanks, how do I reference that in the VBA code?  I looked up ParamArray
in Help and don't see anything.

> Put your arguments into an array, and pass that as a single argument.
>
[quoted text clipped - 7 lines]
> > an error at 61?  Maybe as you suggest the limit is the length of the
> > calling statement rather than the number of elements?
Tony Jollans - 20 Oct 2005 18:12 GMT
Code your macro something like this

Sub mySub(ParamArray myArgs())
For n = LBound(myArgs) To UBound(myArgs)
   ' Do whatever you want with the n'th argument here
Next
End Sub

And call it with as many parameters as you like. ParamArray arrays always
have an LBound of zero and if they are empty they have a UBound of -1.

ParamArray is described in the help for the Sub statement

--
Enjoy,
Tony

> Thanks, how do I reference that in the VBA code?  I looked up ParamArray
> in Help and don't see anything.
[quoted text clipped - 10 lines]
> > > an error at 61?  Maybe as you suggest the limit is the length of the
> > > calling statement rather than the number of elements?

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.