Jump to content

Recommended Posts

Posted

Hi there, 

I'm a newbie with autoit and I have a question : 

I learned alone with the help section how to read in excel's cells or range with autoit and it works fine.

BUT how could I read data on Textboxes in Userform in Excel ? 

What I would like to achieve is to save the Excel's USF Textboxes value / content in a variable on autoit to reuse it after (on Microsoft Dynamic NAV). 

 

Can somebody help me or show me where to find the answer ? 

(Sorry for my English, I'm French)

 

Thank you in advance

Posted

@Nine

 

Hello Nine and thank you for your reply

 

I tried to use something like 

$vartest = GUICtrlRead($TextBox1)

But I have an error message because $TexBox1 is not declared ... 

Please fond attached an Excel file with an example of what I'm trying to do ... 

If you can write me a script for that with a quick explanation it would be perfect .

Test Excel Example.xlsm

Posted

@Nine

 

Just so you know, my excel file homemade  CRM  for my company and it works like a charm. 

It's in full excel VBA language.

I only want to use Autoit to automatically copy and paste some Textboxes content to another software. 

All I'm asking for is an exemple of how to do that. 

So far I wrote an Autoit program with an association of multiples TAB and CTRL+C , CTRL+V  etc to achieve it but It takes like forever because the script is going back and forth between excel and the other programs (plus it's buggy). 

 

So I want to launch an Autoit program from the Excel Userform  (in VBA by clicking a button) and put each textbox content in a single variable in Autotit program. 

Then I will do the other way around to copy each variable from Autoit to the correspondant textboxes in the other program. 

 

I hope a made myself a little bit clearer this time. 

 

Thank you for your help

Posted

Here to start you up (it is not the most elegant way but it does the work) : 

#include <Excel.au3>

Opt ("MustDeclareVars", 1)

Local $oExcel = _Excel_Open(Default, False, Default, Default, True)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "", "Error creating a new Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Local $sWorkbook = @ScriptDir & "\Test Excel Example.xls"
Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "", "Error opening '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
Sleep (500)
MouseClick ("left", 265, 315, 1, 1)
Sleep (500)
Send ("{TAB}{TAB}^c")
Local $Var1 = Clipget ()
Send ("{TAB}^c")
Local $Var2 = Clipget ()
Send ("{TAB}{SPACE}")
_Excel_Close ($oExcel, False, True)

MsgBox (0,"","First Field is " & $Var1 & @CRLF & "Second Field is " & $Var2)

 

Posted

@Nine

 

Thank you for your code but  in fact it is what I already do with my current code. 

What I'm trying to do is improve it and do something like :

 $var1=$Textbox1  

 $var2=$Textbox2 

kinda like

without using the TAB , ctrl+C , ctrl+V etc 

 

I hope I'm making myself clear ... 

 

Posted (edited)
34 minutes ago, NickTriman said:

Thank you for your code but  in fact it is what I already do with my current code. 

Well, you should have post your code first, so I wouldn't have lost my time on it.

I hope I'm making myself clear ... 

Edited by Nine
Posted

The title of my demand is "Read from Excel Userform Textboxes"

Your solution is a workaround but not what I'm searching for as I already did that way

By the way I wrote right before your proposal : 

"So far I wrote an Autoit program with an association of multiples TAB and CTRL+C , CTRL+V  etc to achieve it but It takes like forever because the script is going back and forth between excel and the other programs (plus it's buggy). "

Anyway if you don't know how to do it , no problem or don't want to help further, no problem. 

 

Thank you for your time. 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...