Sign in to follow this  
Followers 0
tradertt

Loop through Excel till it reaches a Blank Cell

6 posts in this topic

Hi guys,

I have a code that will copy from excel and open a webpage. However, I want it to loop though excel till it reaches a blank cell then it will end.

How can I do that?

#include <IE.au3>

Opt("WinWaitDelay", 100)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)

WinWait("Microsoft Excel", "")
If Not WinActive("Microsoft Excel", "") Then _
        WinActivate("Microsoft Excel", "")
WinWaitActive("Microsoft Excel", "")
Send("{CTRLDOWN}c{CTRLUP}")

$sURL = ClipGet()
$oIE = _IECreate($sURL, 0, 1, 0)
$hwnd = _IEPropertyGet($oIE, "hwnd")
WinSetState($hwnd, "", @SW_MAXIMIZE)
WinActivate($hwnd, "")
_IELoadWait($oIE)
_IELinkClickByText($oIE, "Download")
WinWaitActive("File Download")
Sleep (1000)
ControlClick ( "File Download", "&Save", "Button2")
WinWait("Microsoft Excel", "")
If Not WinActive("Microsoft Excel", "") Then _
        WinActivate("Microsoft Excel", "")
WinWaitActive("Microsoft Excel", "")
Send("{RIGHT}{CTRLDOWN}c{CTRLUP}")
WinActivate("Save As", "")
WinWait("Save As", "")
If Not WinActive("Save As", "") Then _
        WinActivate("Save As", "")
WinWaitActive("Save As", "")
Sleep(1000)
Send("{CTRLDOWN}v{CTRLUP}")
ControlClick ( "Save As", "&Save", "Button2")
Sleep(2000)
WinClose ($hwnd, "" )
WinWait("Microsoft Excel","Worksheet Menu Bar")
If Not WinActive("Microsoft Excel - test.xls","Worksheet Menu Bar") Then WinActivate("Microsoft Excel - test.xls","Worksheet Menu Bar")
WinWaitActive("Microsoft Excel - test.xls","Worksheet Menu Bar")
Send("{LEFT}{DOWN}")

Share this post


Link to post
Share on other sites



Hey tradertt,

My last post in the following thread contains a

.zip file that gives an example of one way to do it.

http://www.autoitscript.com/forum/index.php?showtopic=30130

Let me know if this help you or not.

Share this post


Link to post
Share on other sites

Hey tradertt,

My last post in the following thread contains a

.zip file that gives an example of one way to do it.

http://www.autoitscript.com/forum/index.php?showtopic=30130

Let me know if this help you or not.

Search for the

_ExcelCom UDFs

there pretty nice and make doing what you're trying to do easy

Share this post


Link to post
Share on other sites

Errr anyone?

This is how to loop 5 times...

For $i = 1 To 5 Step 1
    ;Your code here... Delete below test MsgBox.
    MsgBox(0, "For Loop", "$i = " & $i)
Next
oÝ÷ Ù*.²)àÊ«r^Ü(ºWe¢,¢g­)à)¶¬jëh×6
#include <IE.au3>

Opt("WinWaitDelay", 100)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)

For $i = 1 To 5 Step 1
WinWait("Microsoft Excel", "")
If Not WinActive("Microsoft Excel", "") Then _
        WinActivate("Microsoft Excel", "")
WinWaitActive("Microsoft Excel", "")
Send("{CTRLDOWN}c{CTRLUP}")

$sURL = ClipGet()
$oIE = _IECreate($sURL, 0, 1, 0)
$hwnd = _IEPropertyGet($oIE, "hwnd")
WinSetState($hwnd, "", @SW_MAXIMIZE)
WinActivate($hwnd, "")
_IELoadWait($oIE)
_IELinkClickByText($oIE, "Download")
WinWaitActive("File Download")
Sleep (1000)
ControlClick ( "File Download", "&Save", "Button2")
WinWait("Microsoft Excel", "")
If Not WinActive("Microsoft Excel", "") Then _
        WinActivate("Microsoft Excel", "")
WinWaitActive("Microsoft Excel", "")
Send("{RIGHT}{CTRLDOWN}c{CTRLUP}")
WinActivate("Save As", "")
WinWait("Save As", "")
If Not WinActive("Save As", "") Then _
        WinActivate("Save As", "")
WinWaitActive("Save As", "")
Sleep(1000)
Send("{CTRLDOWN}v{CTRLUP}")
ControlClick ( "Save As", "&Save", "Button2")
Sleep(2000)
WinClose ($hwnd, "" )
WinWait("Microsoft Excel","Worksheet Menu Bar")
If Not WinActive("Microsoft Excel - test.xls","Worksheet Menu Bar") Then WinActivate("Microsoft Excel - test.xls","Worksheet Menu Bar")
WinWaitActive("Microsoft Excel - test.xls","Worksheet Menu Bar")
Send("{LEFT}{DOWN}")
Next

I hope this helps further your understanding and use of AutoIt,

JS


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

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