Jump to content

Automate Word/Office Testing


Go to solution Solved by Jfish,

Recommended Posts

Hi,

I have an application that you start by clicking a button on the button bar menu of Word. 

How do I tell autoit, which button on the Word button bar to press? For example the button bar says "Format". Is there a way to navigate there and perform the click (i dont want to write macros in Word).

Thanks

 

Link to comment
Share on other sites

What have you tried so far?

The tutorial in the help file named "Simple Notepad Automation" will get you plenty far in the direction you are trying to go.

Give it a shot and come back if you get stuck...

good luck,

Bill

Link to comment
Share on other sites

  • Solution

I am not sure that tutorial will work because the key being pressed is inside a control container and you would need to know the control ID for the button (i.e. format) which is being pressed.  In the VBA code it is listening for private sub formatbutton_click() or something like that.  I don't think the button has an external handle that can be detected (au3info only sees the container). 

However, if the button in question has a shortcut (i.e. CTRL+Shift+C for format painter) you might be able to use the SEND function with the keyboard shortcut - which is the equivalent of pressing the button.  I don't know if VBA would treat that as a "click" (but if you have the code you could test it quickly).  Try going into your Word doc with the VBA code and instead of clicking the button in question use the shortcut.  If your code executes you can send those keys with AutoIt.

***Edit*** one more thought - if you are trying to automate something in Word by simulating a button that kicks off code from AutoIt perhaps consider the Word UDF or COM API to Word that can do whatever your VBA script does.

Edited by Jfish

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

I am not sure that tutorial will work because the key being pressed is inside a control container and you would need to know the control ID for the button (i.e. format) which is being pressed.  In the VBA code it is listening for private sub formatbutton_click() or something like that.  I don't think the button has an external handle that can be detected (au3info only sees the container). 

However, if the button in question has a shortcut (i.e. CTRL+Shift+C for format painter) you might be able to use the SEND function with the keyboard shortcut - which is the equivalent of pressing the button.  I don't know if VBA would treat that as a "click" (but if you have the code you could test it quickly).  Try going into your Word doc with the VBA code and instead of clicking the button in question use the shortcut.  If your code executes you can send those keys with AutoIt.

***Edit*** one more thought - if you are trying to automate something in Word by simulating a button that kicks off code from AutoIt perhaps consider the Word UDF or COM API to Word that can do whatever your VBA script does.

 

Yes, the problem has to do with knowing how to press the button bar. Thanks for your ideas and input.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...