Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Can't call a sub in a UserForm using Application.Run

I'm having problems calling Public Sub XXX that is in Userform1.

Tried

Application.Run "Userform1.XXX"

but will not work. Works OK if XXX is in a Standard Module,

Thanks for any help.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can't call a sub in a UserForm using Application.Run


Is the userform loaded? You aren't suppose to call user form routine
dirrectly. If yo have common code move the macro from the userform to a
module and then call the routine.. You can call the common code from a
userform, right!


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=181173

Microsoft Office Help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Can't call a sub in a UserForm using Application.Run

Try:
Call userform1.xxx

(with userform1 loaded/shown)


Mike wrote:

I'm having problems calling Public Sub XXX that is in Userform1.

Tried

Application.Run "Userform1.XXX"

but will not work. Works OK if XXX is in a Standard Module,

Thanks for any help.


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Can't call a sub in a UserForm using Application.Run

It doesn't matter if it's loaded or not.

Dave Peterson wrote:

Try:
Call userform1.xxx

(with userform1 loaded/shown)

Mike wrote:

I'm having problems calling Public Sub XXX that is in Userform1.

Tried

Application.Run "Userform1.XXX"

but will not work. Works OK if XXX is in a Standard Module,

Thanks for any help.


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Can't call a sub in a UserForm using Application.Run

It appears that Application.Run can be in a Standard Module, a Class Module
or a Userform module and it cannot call a sub in a Userform Module. Thanks.
"joel" wrote in message
...

Is the userform loaded? You aren't suppose to call user form routine
dirrectly. If yo have common code move the macro from the userform to a
module and then call the routine.. You can call the common code from a
userform, right!


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread:
http://www.thecodecage.com/forumz/sh...d.php?t=181173

Microsoft Office Help





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Can't call a sub in a UserForm using Application.Run

The reason I have to use Application run is because I need the XXX to be a
variable, like

dim zzz as string

zzz= "Userform1.xxx"

Application.Run zzz

The Call userform1.xxx does work but "Call" can't take a variable.

Thanks Peter

"Dave Peterson" wrote in message
...
Try:
Call userform1.xxx

(with userform1 loaded/shown)


Mike wrote:

I'm having problems calling Public Sub XXX that is in Userform1.

Tried

Application.Run "Userform1.XXX"

but will not work. Works OK if XXX is in a Standard Module,

Thanks for any help.


--

Dave Peterson



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Can't call a sub in a UserForm using Application.Run

The Call userform1.xxx does work but "Call" can't take a variable.

Use CallByName. E.g., in a regular code module


Sub AAA()
Dim FF As UserForm1
Dim S As String
S = "HelloWorld"
Set FF = New UserForm1
CallByName FF, S, VbMethod
End Sub

Here, HelloWorld is a method defined in UserForm1's code module. You
need to create an instance of UserForm1 but you need not Show the form
to make it visible.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com




On Sun, 21 Feb 2010 06:29:05 -0800, "Mike"
wrote:

The reason I have to use Application run is because I need the XXX to be a
variable, like

dim zzz as string

zzz= "Userform1.xxx"

Application.Run zzz

The Call userform1.xxx does work but "Call" can't take a variable.

Thanks Peter

"Dave Peterson" wrote in message
...
Try:
Call userform1.xxx

(with userform1 loaded/shown)


Mike wrote:

I'm having problems calling Public Sub XXX that is in Userform1.

Tried

Application.Run "Userform1.XXX"

but will not work. Works OK if XXX is in a Standard Module,

Thanks for any help.


--

Dave Peterson


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Can't call a sub in a UserForm using Application.Run

Thanks Chip. That's exactly what I need. Works great!!


"Chip Pearson" wrote in message
...
The Call userform1.xxx does work but "Call" can't take a variable.


Use CallByName. E.g., in a regular code module


Sub AAA()
Dim FF As UserForm1
Dim S As String
S = "HelloWorld"
Set FF = New UserForm1
CallByName FF, S, VbMethod
End Sub

Here, HelloWorld is a method defined in UserForm1's code module. You
need to create an instance of UserForm1 but you need not Show the form
to make it visible.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com




On Sun, 21 Feb 2010 06:29:05 -0800, "Mike"
wrote:

The reason I have to use Application run is because I need the XXX to be a
variable, like

dim zzz as string

zzz= "Userform1.xxx"

Application.Run zzz

The Call userform1.xxx does work but "Call" can't take a variable.

Thanks Peter

"Dave Peterson" wrote in message
...
Try:
Call userform1.xxx

(with userform1 loaded/shown)


Mike wrote:

I'm having problems calling Public Sub XXX that is in Userform1.

Tried

Application.Run "Userform1.XXX"

but will not work. Works OK if XXX is in a Standard Module,

Thanks for any help.

--

Dave Peterson




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Call Search Application Pedro Excel Programming 1 August 7th 07 02:28 PM
Failure with Excel.Application Call newKev Excel Programming 0 January 30th 07 02:18 PM
Call procedure using Application.Run xlcharlie Excel Programming 7 February 1st 06 08:45 PM
Application.Run Call Err: 1004 Cannot Find Macro Travich Excel Programming 6 December 7th 05 07:08 PM
Call other application from excel A-Design Excel Programming 6 November 19th 04 10:13 PM


All times are GMT +1. The time now is 09:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"