×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Word VBA - Call Private Sub on userform from module

Word VBA - Call Private Sub on userform from module

Word VBA - Call Private Sub on userform from module

(OP)
I have tryed:
Application.Run UserFormName & "." & "Private Sub Cmd_Save_Click"
But get the error msg: Unable to run the specified macro
I know that the Sub is there and Application.Run should do the trick.
So what am I doing wrong or cat this be done owing to the fact that this is a private sub ?

Herman
Say no to macros

RE: Word VBA - Call Private Sub on userform from module

>I know that the Sub is there and Application.Run should do the trick.

Application.Run basically cannot call class methods. And a form is a class ...

CallByName works, though, but the first parmeter needs to be the object in question, not a string (but that's OK, becasue we've covered how to get to the form object from string name in thread707-1783526: Word VBA - Using an array to view form)

CallByName UserForm1, "CommandButton1_Click", VbMethod

RE: Word VBA - Call Private Sub on userform from module

Or you can do this ( I think.... I hope....):

CODE --> Form

Option Explicit
...
Private Sub Cmd_Save_Click()
Call MySaveMagic
End Sub
... 

and in the standard Module:

CODE --> Module

Option Explicit
...

Public Sub MySaveMagic()
    'My code to save stuff...
End Sub
... 

Then you just do: Application.Run MySaveMagic


---- Andy

There is a great need for a sarcasm font.

RE: Word VBA - Call Private Sub on userform from module

> I think.... I hope....

oops ... it would be

Application.Run "MySaveMagic"

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close