Jump to content

Need Help With Automating Excel


Recommended Posts

I am trying to automate several different functions in excel through an autoit script but it wont allow me to use vba functions like .Run or .ActiveWorksheet I've seen people using them in their autoit script on the forum but autoit wont allow me to use them any help would be very appreciated.

Link to post
Share on other sites

I have gotten the Excel UDFs to work but the problem comes when I try to control the excel workbooks from autoit.

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

Sleep(1000)

Global $bBook = "\\NeRD_LAB\Lab\Student Folders\Daylin\SiO2_68\Peak Fitting\Al2O3\Seq1\SiO2_68_D-spacings_Seq1_Al2O3(copy).xlsm"

_Excel_BookAttach($bBook)

$bBook.Run("DspacingsAllPeaks")

here is a quick test code I was working with. The Excel udf's work fine, for example if I were to use _Excel_BookClose it will close the instance of excel if I have it open. but when I try to run the macro with .Run command it says it doesn't recognize .run as anything the same goes for if I were to try and switch the active worksheet with .ActiveWorksheet

Link to post
Share on other sites

I see. You do not understand how the UDF is working.  You need to create an object and use the object to do some other actions.

In your snippet, you are using a string to perform the actions, which of course won't work.  You need to create the object with you attach statement (see return value).

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...