ThomasQ Posted August 6, 2009 Share Posted August 6, 2009 Hi! I'm fairly new at all this, so I was hoping you could help a n00b out! I'm trying to copy paste an url into an excel sheet, here is where it goes wrong: $oLinks = _IELinkGetCollection ($oIE) $url=$oLinks.href _ExcelWriteCell ($Cleansheet, $url, "D4") How do I specify which one of the $oLinks collection I want to be $url?? Many Thanks!! Link to comment Share on other sites More sharing options...
Skruge Posted August 6, 2009 Share Posted August 6, 2009 Look at the help file example for _IELinkGetCollection. You need a For...In...Next loop to step through each link in the collection. [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
ThomasQ Posted August 6, 2009 Author Share Posted August 6, 2009 So i have to make some sort of loop? I've had some problems with that with other scripts. Could someone please explain a little bit how this is done with this example? Then Ill know once and for all.. Thanks! Link to comment Share on other sites More sharing options...
Skruge Posted August 6, 2009 Share Posted August 6, 2009 So i have to make some sort of loop? I've had some problems with that with other scripts. Could someone please explain a little bit how this is done with this example? Then Ill know once and for all.. Thanks! In order to reference the values in a collection, you have to use a For...In...Next loop. If you have multiple links but only want a single one, you'll have to add your own conditions. Taken straight from the help file example for _IELinkGetCollection: For $oLink In $oLinks MsgBox(0, "Link Info", $oLink.href) NextPut whatever conditions in that you need in, and swap out the MsgBox with _ExcelWriteCell. [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
ThomasQ Posted August 7, 2009 Author Share Posted August 7, 2009 Ok ok Thanks! It helped a little bit, and i'm a bit clearer on arrays and the use of them. Still I have no succes, this is how far I got: $oExcel = _ExcelBookOpen("C:\Documents and Settings\Q\Desktop\Projects\Sheets\KlantNummers.xls",1,True) $oIE = _IECreate ("http://www.google.nl") $oLinks = _IELinkGetCollection ($oIE) $iNumLinks = @extended MsgBox(0, "Link Info", $iNumLinks & " links found") For $oLink In $oLinks _ExcelWriteCell ($Cleansheet,$oLinks, "D4") Next This code writes the first one to cell D4. Last thing I need now is to be able to chose by index number wich URL is written. Once again I apologize for being an ultimate n00b! >_< Thanks in advance!! Link to comment Share on other sites More sharing options...
Skruge Posted August 7, 2009 Share Posted August 7, 2009 This code writes the first one to cell D4. Last thing I need now is to be able to chose by index number wich URL is written.I'm not sure of a way to reference a link directly by index (Like you can with an array). Perhaps someone who does can chime in. This should work, though: Local $iLinkIndex = 7 ; Change this to the index you want Local $iCurrentIndex = 0 For $oLink In $oLinks $iCurrentIndex += 1 If $iCurrentIndex = $iLinkIndex Then _ExcelWriteCell ($Cleansheet,$oLink.href, "D4") ExitLoop EndIf Next [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
DaleHohm Posted August 7, 2009 Share Posted August 7, 2009 _IELinkGetCollection has an optional index parameter that does just that. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
Skruge Posted August 7, 2009 Share Posted August 7, 2009 _IELinkGetCollection has an optional index parameter that does just that. DaleI don't know how I missed that! I need to follow my own advice.I even looked at the source for IEBuilder to see how it got the link indexes.(Granted, it loops through them all so that it can display them all)Thanks again, Dale. [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
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