Consulting

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

Thread: run macros from windows

Hybrid View

Previous Post Previous Post   Next Post Next Post
  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 Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    4,241
    Location
    Can you post your workbook so we can see what you currently have?
    Remember To Do the Following....
    Use 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 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?

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,797
    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

  5. #5
    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

  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
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,797
    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
    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

  12. #12
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    4,241
    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 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

  13. #13
    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

  14. #14
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    4,241
    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 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

  15. #15
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,397
    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

  16. #16
    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 ?

  17. #17
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    4,241
    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 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

  18. #18
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    4,241
    Location
    Upload your file so we can see what you currently have.
    Remember To Do the Following....
    Use 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
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,397
    Location
    Quote Originally Posted by mtplmtpl View Post
    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

    Glad it worked. To attach a file the next time, write your text then ...

    1. Click [Go Advanced] below and to the right
    2. Click the 'Paperclip' icon
    3. Click [Add Files]
    4. Click [Choose File]
    5. Browse to the file to upload
    6. Select the file, click [Open]
    7. Click [Upload] on the Add Files dialog

    Capture.JPGCapture1.JPGCapture2.JPG

    Some annoyances I find --

    1. You can only add one file at a time, no multiselect
    2. Some file types cannot be uploaded
    3. There is a reasonable (?) limit on file size
    4. You can [Insert Inline] like the screenshots above or [Done] to have them in the [Attached Files] area

    Capture4.JPG
    ---------------------------------------------------------------------------------------------------------------------

    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

Posting Permissions

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