PDA

View Full Version : [SOLVED:] run macros from windows



mtplmtpl
04-04-2022, 01:55 PM
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

Aussiebear
04-04-2022, 02:28 PM
Can you post your workbook so we can see what you currently have?

SamT
04-04-2022, 06:52 PM
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

mtplmtpl
04-05-2022, 12:07 AM
Thank very much I' try your recommendations. Thank you again


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

mtplmtpl
04-05-2022, 12:12 AM
Thank you very much

Can you post your workbook so we can see what you currently have?

mtplmtpl
04-05-2022, 01:07 PM
Thank very much I' try to use your recommendations. Thank you again

mtplmtpl
04-07-2022, 04:15 AM
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.

SamT
04-07-2022, 05:18 AM
In Windows, One click means "Select". Two clicks means "Open" or "Run". Except sometimes.

mtplmtpl
04-07-2022, 06:27 AM
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.

mtplmtpl
04-07-2022, 10:53 AM
2959229593
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.

Aussiebear
04-07-2022, 11:44 AM
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

mtplmtpl
04-07-2022, 01:07 PM
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

Aussiebear
04-07-2022, 01:36 PM
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?

Paul_Hossler
04-08-2022, 05:39 PM
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

29600

4. You'll still have to Enable Macros

5. Examine code in ThisWorkbook, UserForm1, and Module1

mtplmtpl
04-09-2022, 12:26 AM
2959229593
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

Aussiebear
04-09-2022, 02:31 AM
@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?

mtplmtpl
04-29-2022, 12:15 PM
Thank you. It works very well. it opens workbook. I'd like to open my macro. is it possible ?

Aussiebear
04-29-2022, 01:05 PM
Upload your file so we can see what you currently have.

mtplmtpl
04-30-2022, 12:01 AM
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

Aussiebear
04-30-2022, 01:08 AM
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

mtplmtpl
04-30-2022, 01:48 AM
the file(test-db.xlsm) is text file because it has empty code. thank you very much.( with 1 macro)

Paul_Hossler
04-30-2022, 02:32 PM
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

296872968929688

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 area

[ATTACH=CONFIG]29690

Paul_Hossler
04-30-2022, 05:39 PM
1. I don't understand your comment


the file(test-db.xlsm) is text file because it has empty code. thank you very much.( with 1 macro)



2. I don't understand your overall intent


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


3. Go back and read Post #14


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



4. Just save the attached XLSM and then double click it. Look at code in ThisWorkbook module, UserFOrm1, and Module1

29694

Aussiebear
04-30-2022, 05:48 PM
@mtplmtpl. the file you uploaded is meaningless. Where is the file you talked about in your initial post? Did you look at the example (Demo.xlsm) the Paul_Hossler kindly provided for you?

I seriously doubt that you did for if you had done so you will have seen a perfectly good example of a workbook upon opening loading a Userform1 and only showing the Userform. On that Userform is a Command Button which when clicked "calls" the Sub Hello module which simply displays a message "Hello!!".

If you haven't do so by now I request that you pause here and do so by saving Paul's file to your system, locate the file by using File Explorer, Double click on the file Demo.xlsm and click on the Command Button that is embedded on the Userform. This example does everything you asked for. When you are ready to try to understand the structure of the workbook, select Developer section ( Alt F11 in Microsoft systems I believe). The workbook contains a Userform1 and three modules. If you click on THisworkbook you will find the 1st, click on Userform1 to find the second, Click on Module1 to find the third.

29691
Click on Thisworkbook to find the 1st module. It is this module which upon the workbook opening, loads and shows the Userform1.


29696


Click on UserForm1 to find the second module, in which the command button function calls the Sub Hello()

29692


Click on Module 1 to find the 3 section of code, namely the Sub Hello()

29693

Once you have done this you should now understand where to place your sections of code, how to construct them, and the reasoning behind the structure.

In your very first post you talked about having constructed a Userform and a macro. Unless you are prepared to upload the workbook upon which you are attempting to design your Userform, we are very limited in giving you precise assistance.

Paul_Hossler
04-30-2022, 07:23 PM
@AussieBear -- roger that

@mtplmtpl -- I tried to make sense of your second file - text-db - and guessed at some things that might give you the idea about how to structure your workbook since the other suggestions from myself, Aussiebear and other did not seem to take

Hopefully, you can relate better to test-db and see where things need to go. Save it somewhere you can find it and then double-click the XLSM file in Explorer

Other than that, I'm out of ideas

mtplmtpl
05-02-2022, 01:57 AM
Dear admin and Paul. Everything works very good according to your recommendations. thank you very much and sorry