soonyee91 Posted June 13, 2013 Posted June 13, 2013 After few search on the internet, I still cannot figure this out. Any tips on doing it? Is it the way i declare the window object wrong? Below is my code: #include <Excel.au3> #include <File.au3> Global $szDrive, $szDir, $szFName, $szExt ,$filelocation="C:\Users\SoonYee\Desktop\test.xls" Global $oExcel = ObjCreate("Excel.Application") $oExcel.Visible = 1 $oExcel.Application.ScreenUpdating = True $oExcel.Application.DisplayAlerts = False $oExcel.WorkBooks.Open($filelocation,2 ) Dim $view=_PathSplit($filelocation, $szDrive, $szDir, $szFName, $szExt) Local $arr[3] = ["Graph", "Rawdata", "Data_t50"] $oExcel.Sheets($arr).Printout WinWaitActive("Save As") WinActivate ( "") ControlSend ( "[CLASS:#32770", "", "Edit1", "Testing purpose") The code run fines up to open the file. For controlsend part, it is not working. Where is the problem actually??
soonyee91 Posted June 13, 2013 Author Posted June 13, 2013 After a few tries, I am able to automate the "Save As" Dialog If I open the excel separately without using the above code. ControlSetText("Save As","",1001,"Testing") Above code works If I do not use together with the 1st post's code. Any idea why I am unable to send text to the control?? if I put this code on my 1st post's code. For example: #include <Excel.au3> #include <File.au3> Global $szDrive, $szDir, $szFName, $szExt ,$filelocation="C:\Users\SoonYee\Desktop\test.xls" Global $oExcel = ObjCreate("Excel.Application") $oExcel.Visible = 1 $oExcel.Application.ScreenUpdating = True $oExcel.Application.DisplayAlerts = False $oExcel.WorkBooks.Open($filelocation,2 ) Dim $view=_PathSplit($filelocation, $szDrive, $szDir, $szFName, $szExt) Local $arr[3] = ["Graph", "Rawdata", "Data_t50"] $oExcel.Sheets($arr).Printout ControlSetText("Save As","",1001,"Testing") Any reason why the code is not performing??
Solution soonyee91 Posted June 14, 2013 Author Solution Posted June 14, 2013 (edited) Haha, looks like the respond is good... I manage to figure out... Instead of using this vba line "expression.Printout". I change it to "expression.Select". After this I choose to use either send/controlsend function for automate the task. To avoid user input from disturbing the operation. I implement "Blockinput()". That's all for this problem. Solved! Edited June 14, 2013 by soonyee91
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now