Consulting

Page 1 of 2 1 2 LastLast
Results 1 to 20 of 26

Thread: run macros from windows

  1. #1
    VBAX Regular
    Joined
    Apr 2022
    Posts
    13
    Location

    run macros from windows

    I am working with userform for the first time. I made a macro text3 (there is this code in module1), created a form userform1, with one click button, I can't run my macros text3 from this form. By clicking on the run button, I automatically get to a module. There I see two sub... end sub. It is necessary to write code inside of the module. I don't know what exactly. Similarly with another form, it is necessary to reflect the message from msgbox on it. Help

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,213
    Location
    Can you post your workbook so we can see what you currently have?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,709
    Location
    The Code that a CommandButtopn runs should be in the Commandbutton_Click() Sub, Unless you need it to run with Other Controls. It should only be ina Module if it will be used outside the UserForm
    CBut Code
    Sub CButton1_Click()
       Code from text3 Here
    End Sub
    Multi Form Control Code
    Sub CButton1_Click()
       Text3
    End Sub
    
    'UserFormCode:
    Sub text3()
       blahblah
    End Sub
    MultiUse Code
    'UserForm Code
    Sub CButton1_Click()
    Module1.text3
    End Sub
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  4. #4
    VBAX Regular
    Joined
    Apr 2022
    Posts
    13
    Location

    run macro from windows

    Thank very much I' try your recommendations. Thank you again

    Quote Originally Posted by SamT View Post
    The Code that a CommandButtopn runs should be in the Commandbutton_Click() Sub, Unless you need it to run with Other Controls. It should only be ina Module if it will be used outside the UserForm
    CBut Code
    Sub CButton1_Click()
       Code from text3 Here
    End Sub
    Multi Form Control Code
    Sub CButton1_Click()
       Text3
    End Sub
    
    'UserFormCode:
    Sub text3()
       blahblah
    End Sub
    MultiUse Code
    'UserForm Code
    Sub CButton1_Click()
    Module1.text3
    End Sub

  5. #5
    VBAX Regular
    Joined
    Apr 2022
    Posts
    13
    Location
    Thank you very much
    Quote Originally Posted by Aussiebear View Post
    Can you post your workbook so we can see what you currently have?

  6. #6
    VBAX Regular
    Joined
    Apr 2022
    Posts
    13
    Location
    Thank very much I' try to use your recommendations. Thank you again

  7. #7
    VBAX Regular
    Joined
    Apr 2022
    Posts
    13
    Location
    Sorry. I think yesterday I sent you this message, but to the wrong address. That's why I'm repeating it today. I keep trying to make code to run my program code from Windows. My task is that when I click on the address of my file from Windows (in Windows Explorer), then Excel should open my user form with one click. From it I will run my program. I have tried your suggestions but have not been successful. Because of my main problem - I'm a beginner. In this situation, is it possible for you to send me a fragment of the program, where the code recommended by you would already be used. Excuse me please.

  8. #8
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,709
    Location
    In Windows, One click means "Select". Two clicks means "Open" or "Run". Except sometimes.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  9. #9
    VBAX Regular
    Joined
    Apr 2022
    Posts
    13
    Location
    Certainly. When I double click it opens my database. I need to open the place where my userform is displayed . if it is possible. thank you and sorry.

  10. #10
    VBAX Regular
    Joined
    Apr 2022
    Posts
    13
    Location
    for-d.b-excel.jpgform-excel.jpg
    When i make twice click on the address of my file in Windows Explorer then i see left picture but i'd like to get right picture.

  11. #11
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,213
    Location
    Talk about running around in a circle... From what I understand you ar requiring a Userform to become visible upon opening of a particular workbook.
    Private Sub Workbook_Open()
    Userform1.Show     <- change to correct name of Userform
    End Sub
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  12. #12
    VBAX Regular
    Joined
    Apr 2022
    Posts
    13
    Location
    but how to run from windows explorer? after than I will use your code. exactly- user clicks on the address of file in windows and he see form1 on his computer. thank you and sorry

  13. #13
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,213
    Location
    I don't have a Microsoft system, but from reading your previous comments and those of SamT, once you have the file address in Explorer did you try the double click function that you both talked about?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  14. #14
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,768
    Location
    Cookbook approach

    1. Save the attachment to your Documents folder

    2. Change to your Documents folder and find the file

    3. Double click the file

    Capture.JPG

    4. You'll still have to Enable Macros

    5. Examine code in ThisWorkbook, UserForm1, and Module1
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  15. #15
    VBAX Regular
    Joined
    Apr 2022
    Posts
    13
    Location
    Quote Originally Posted by mtplmtpl View Post
    for-d.b-excel.jpgform-excel.jpg
    When i make twice click on the address of my file in Windows Explorer then i see left picture but i'd like to get right picture.

    Sam.T I take my hat off to your professionalism and patience to help beginners. Thank you

  16. #16
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,213
    Location
    @mtplmtpl Did you look you even look at the example provided by Paul_Hossler? Paul clearly shows how to open a file from Windows Explorer and have that file upon opening, show the userform. SamT has given you the basics for doing the same thing but you don't seem willing to do the fundamentals as indicated. You posted your response some 7 hours after getting Paul_Hosslers reply.... which suggests to me that you didn't even evaluate his suggestion. Why should people even want to assist you?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  17. #17
    VBAX Regular
    Joined
    Apr 2022
    Posts
    13
    Location
    Thank you. It works very well. it opens workbook. I'd like to open my macro. is it possible ?

  18. #18
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,213
    Location
    Upload your file so we can see what you currently have.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  19. #19
    VBAX Regular
    Joined
    Apr 2022
    Posts
    13
    Location
    I am very grateful to those who help me. wrote about this many times. SamT and Paul Hossler. I spend a lot of time to understand the answer. Now Sorry, I can't because I can't find the icon in the forum (I found how to download a photo and a picture, but not a file). excuse me. i try

  20. #20
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,213
    Location
    In your next reply, click on Go Advanced/ Manage Attachments and choose your file. Upload from there bearing mind there are size limits to certain types of files
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •