Sign in to follow this  
Followers 0
hg2052

Can write table content from a web page to excel using IE9 but not IE7

20 posts in this topic

Hi!

I have the following code to retrieve table content of a web page and write it to Excel 2007.It works fine with IE9, but nothing is written to he spreadsheet when I try to use IE7.

Can someone give a solution (except giving up IE7)?

Thanx.

If StringFormat($line)"" Then

$adress="http://www.xxx.yyy/vvvvvv/" & StringFormat($line)

Local $oIE=_IECreate("http://www.xxx.yyy")

Sleep(2000)

_IENavigate($oIE,$adress,1)

_IELoadWait($oIE)

Sleep(10000)

$body = _IEBodyReadHTML($oIE)

Local $sHTML = _IEBodyReadHTML($oIE)

If StringInStr($body,'',2) 0 Then

FileWriteLine("Found.txt",$line)

$j=$j+3

$vgt=VarGetType('')

$oTable = _IETableGetCollection($oIE)

Local $iNumTables = @extended

$oTable = _IETableGetCollection ($oIE, $iNumTables-1)

$aTableData = _IETableWriteToArray ($oTable)

If $j>2 Then

_ArrayDelete($aTableData,0)

EndIf

_ExcelWriteSheetFromArray($oExcel, $aTableData, $j, 1, 0, 0)

Sleep(1000)

_IEQuit($oIE)

If @error Then ExitLoop

EndIf

_IEQuit($oIE)

EndIf

_ExcelBookSaveAs($oExcel, 'DestFile.xls',0,1)

_ExcelBookClose($oExcel, 0, 0)

Share this post


Link to post
Share on other sites



If you run your script from SciTE do you get any error messages in the output pane?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

No message.

Share this post


Link to post
Share on other sites

Then please add line

_ArrayDisplay($aTableData)

after the following line to check if the table was populated by IE.

$aTableData = _IETableWriteToArray ($oTable)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Nothing is displayed. In fact, I've already checked this.

Share this post


Link to post
Share on other sites

Then line

$aTableData = _IETableWriteToArray($oTable)

doesn't create the table.

What's the value of @error after the above line?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

No error message is displayed (remember,it works flawlessly with IE9; the bug appears only with IE7).

Share this post


Link to post
Share on other sites

I was not asking for an error message but for the value of @error. That's a big difference!


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I meant:there is no @error. Simply, the program goes on, without writing anything to Excel.

Share this post


Link to post
Share on other sites

There is always @error because it is a macro created by AutoIt. If $aTableData is not an array then there must be an error somewhere in your script.

You are sure the posted code is the code you run?

This statement really looks suspicious:

If StringFormat($line)"" Then

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

You're suspicious, but the code executes with on a computer with IE9, but not with IE7. There is only one detail I didn't mention : IE7 displays, at the left lower corner,"Done, but with errors on page". Maybe one of these errors is responsible for what you consider looking suspicious. But I don't know which are IE7's errors.

Share this post


Link to post
Share on other sites

The code you posted in post#1 can't be executed because you get a syntax error:

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /prod /AU3Check /in "C:\Temp\Test.au3"
+>20:26:40 Starting AutoIt3Wrapper v.2.1.2.9    Environment(Language:0407  Keyboard:00000407  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64)
>Running AU3Check (1.54.22.0)  from:C:\Program Files (x86)\AutoIt3
C:\Temp\Test.au3(2,25) : ERROR: syntax error
If StringFormat($line)""
~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Temp\Test.au3 - 1 error(s), 0 warning(s)
!>20:26:40 AU3Check ended. Press F4 to jump to next error.rc:2
>Exit code: 0    Time: 0.879

Which code do you execute?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

$line has been declared somewhere else in the program (which you should have guessed, I guess), so that's you get the error: Local $line = FileReadLine($file,Number($i)) I don't understand you: are you trying to help, or to find errors to please yourself?

Share this post


Link to post
Share on other sites

Please again have a look at the error messages above! There are two double quotes (in bold and red below) in your original post and the error message I posted that give you a syntax error. This means that your code is unable to run!

If StringFormat($line)""


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

hg2052,

which you should have guessed, I guess

If you want help the best way is to post code that we can run - why should we be expected to guess at what variables are declared or not? :huh:

I don't understand you: are you trying to help, or to find errors to please yourself?

In my opinion, water was being remarkably patient.  i use the past tense advisedly - because if you were to speak to me like that that would be the end of any help you received.  Might I suggest losing the attitude? ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Water, Here you're right;but it's only a copying error, because in the program it is If StringFormat($line)<>"" Then M23, you're free in your suggestions.But I guess everybody would better enjoy freedom in Autoit than... Good night!

Share this post


Link to post
Share on other sites

StringFormat doesn't work like that, it needs at least one variable after the format string, your code line has neither. There's no format string, and there's no variable. That command could be written like "If $line <> "" then" and achieve the same result, the StringFormat function isn't doing anything.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Isn't $line that variable? 

Yes, you're right it's a variable. But as it seems you missed the important point I'll repeat it, you're using StringFormat in a pointless way. You don't need it in your script, because it doesn't affect the outcome of using it or not using it.  So why bother using a function that you're using wrong and doesn't need to be there?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Thank you, Ill try this AGAIN, but I remember I started do without StringFormat an d it didn't work.

I think also about using thr table's name "Block 5" or4 or 6 or...etc instead of a table identifier.

However, I exprct most from using what had been suggested in the links I mentioned.

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