Sign in to follow this  
Followers 0

Send text to VBA form

10 posts in this topic

#1 ·  Posted (edited)


I want to send text into a VBA form's text field. Can someone please guide me on the autoit script that can help me.

Below is the sample code that I need help on:

#include <Excel.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>

@ScriptDir ="D:\\AutoIT\"
$sFilePath = @ScriptDir & "\ExcelForm.xlsm"

Local $oAppl = _Excel_Open()
;Local $oAppl = _Excel_Open(False, Default, Default, Default, True)
Local $sWorkbook = $sFilePath
Local $oWorkbook = _Excel_BookOpen($oAppl, $sWorkbook)

ConsoleWrite('before opening macro.........1')

ConsoleWrite('After opening macro.........1')

Send('First text')
ConsoleWrite('After opening macro.........2')
ConsoleWrite('After opening macro.........3')
Send('Second text')
ConsoleWrite('After opening macro.........4')
ConsoleWrite('After opening macro.........5')



Edited by Melba23
Added code tags

Share this post

Link to post
Share on other sites


Please pay attention to where you post - the "Developer General Discussion" section where you started this thread is not for general support questions.  I have moved it for you, but would ask you to be more careful in future.

And when you post code please use Code tags - see here how to do it.  Then you get a scrolling box and syntax colouring as you can see above now I have added the tags.




Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
Share on other sites

Hi junkew,


I refered number 31,

but here my macro is not processing further. So after running macro, it openup macro, but didnot move ahead with send/sendcontrol or tabs.

do i have to do any settings in excel macro?

Share this post

Link to post
Share on other sites


On 5/17/2016 at 7:20 PM, RamPalav said:
@ScriptDir ="D:\\AutoIT\"


first, you do not assign a value to an internal AutoIt macro. it is populated automatically. remove that line.

now, what you do is this: read the tutorial "Simple Notepad Automation" (in the help file, AutoIt \ Tutorials). this tutorial explains:

1) how to wait for the form to appear, instead of using Sleep().

2) how to use the AutoIt Windows Info tool to analyze the VBA form and find the controls you need to manipulate.

once you know what the controls are called, you can substitute you Send() calls with ControlSend(), which eliminate the need for tabbing and in general makes your script more robust.


now for a different aspect. VBA is used to automate Excel, and you wish to use AutoIt to automate the VBA. are you seeing something odd here? how about a change of approach - make your VBA code, before calling the form, get the text to fill (from wherever AutoIt takes it) and populate the form - and perhaps you can skip the form step altogether.

Share this post

Link to post
Share on other sites

The VBA files (Containing series of multiple forms) which i  get is protected and not able to edit those. So I need to send the data to it along with button click to get the result and end of last form.

The issue was I was able to run macro but it was not able to pass the data to text boxes, combo box, buttons etc.

I found a work way around creating a new exe through C# and calling them through AutoIT. May be it is not the correct way!!

Thanks for your support!



Share this post

Link to post
Share on other sites


do not call the macro, create a button on excel and assign macro to it and click that button with mouse click

and done.


Share this post

Link to post
Share on other sites

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
Sign in to follow this  
Followers 0

  • Similar Content

    • SkysLastChance
      By SkysLastChance
      I have a Razer Blackwidow Ultimate keyboard that has 5 extra keys marked M1 - M5. I was wondering if I would be able to setup Macros in AutoIt using these.
      I saw that Fn key is not possible. 
      I am also aware that the M1 keys work with razor snyapse. However, I am at work and can't download that program.
      If someone could let me know and point me in the right direction if it is possible I would be grateful.
    • TheAutomator
      By TheAutomator
      How can you get the downloads folder in AutoIT?
      As far as i know there isn't a macro for it right? like @Downloads or something?
      The ugly solution would be typing in the whole path but what if the user has chosen another location?
      Need to clear that folder regularly on my work and on different accounts..
      regards, TheAutomator
    • afzalw
      By afzalw
      I am using Autoit to automate another software.  I am looking to create a piece of code which can select the option from a combo box.  I know what option I want to select and I have stored it in a string but nothing seems to be working for me. 
      I am able to click on the Control by using this code.
      ControlClick("Import/Export Table Name", "","[NAME:cmbTableName]"); This is what I was thinking but doesn't work for me.
      ControlCommand("Import/Export Table Name", "", "[NAME:cmbTableName]", "SelectString", $MyOptionName)  
      If it helps: The option name that I want to select is also stored in clipboard.
      Any comments on what am I missing here will be appreciated.
    • ur
      By ur
      I wrote a macro for outlook to send an email.
      Till yesterday it worked, don't know why it is not working today
      I am getting below error when I ran the macro.

    • 31290
      By 31290
      Hi everyone, 
      I'm writing a tool that will help my technician adding a user in the local admin group. 
      1- As the user, at first, is not part of the group, launching the .exe file ask for admin credentials. Thing is, whereas I'm using 
      RunWait(@ComSpec & ' /c ' & 'Net LocalGroup Administrators' & @username & ' /add' ,"") The @username macro is taking the admin user account in the variable instead of the current logged user one.
      Do you know how can I face this and have the "real" username value returned?
      2- do you guys think it's possible to give the admin access temporary? Maybe something to write in the reg? task scheduler? compare dates and execute a .exe? etc...?
      Thanks in advance