like beatin a dead horse

T

tad_wegner

....macros controlling macros and userforms from remote workbooks...

a macro from workbook-A opens a 'userform' in workbook-B, then fills it
out. there is a 'commandButton' on the 'userform' of workbook-B... how
do i activate this 'commandButton' from my macro in workbook-A ?
 
T

Tom Ogilvy

The easiest would be to put any code that you want accessible from
workbook-A in general modules. Have the events in the userform call these
procedures.

rather than

Private Sub Commandbutton1_click()
msgbox "Click"
End sub

do

In a general module

Sub btnClick()
msgbox "Click"
End Sub

then in the userform Module

Private Sub Commandbutton1_click()
btnClick
End Sub

then in workbook A you can do

Application.run "WorkbookA.xls!btnClick"

However, it appears to me your whole approach is flawed.

the userform should probably be in Workbook - A. You can easily write the
code for the userform to use data from the Active workbook or any other
workbook you want to reference.
 
T

tad_wegner

tom-

thanks for your response... i tried it (at least how i interperete
what you wrote), however it did not work.

what happened is that my macro from workbook-A opened the userform i
workbook-B and filled it out, then paused. when i clicked th
"commandbutton" a msgbox popped up. i had to "OK" it, then th
commandbutton "action" happened. so it looks like i onl
"boobie-trapped" the commandbutton on the userform, i didnt actuall
get it to "click" from my macro in workbook-A. im confused...

i couldnt agree more about the method being flawed from the git-go
without getting too wrapped up in details, the nature of what i want t
do is very complex and has many steps.
- i developed a very large tool 'workbook-A'
- another engineer developed an even larger tool 'workbook-B'. his too
uses vast amounts of userforms to collect and display data (i kno
little about userforms, but much about macros in general, according t
me)

-combining workbooks wouldnt make this easier for me, i still need t
know how to activate his userform "commandbutton"s to automate ou
analyses. both processes are very iterative and do hundreds o
thousands of calcs (each) so i want to 'batch' all our macros togethe
so i (we) dont have to feed the workbooks any additional data after w
press the "go" button. the problem is his userforms are huge an
complicated and i dont want to look through all the code to bypass th
form... id rather fill the userform out like he wanted and submit the
like they would normally be done. BTW he is no longer here, so thi
makes it very difficult.

please, can you instruct me one more time... last time it didnt work.
thanks
 
T

Tom Ogilvy

Looks like you are trying to write some kind of keystroke macro. Afraid
that is not something I can help you with.

Use SendKeys. Use Excel VBA help.

However, your short term solution will probably result in long term pain.
Better to invest the time and understand his code then figure out how to
integrate. I would see no userforms being shown from his application, but
you applying the data to the routines that his userforms would call. Still,
its not something I have to do and you do have to.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top