Jump to content

Errors $oExcel.Activesheet.Cells($sRangeOrRow, $iColumn).Value = $sValue


Recommended Posts

Hi everybody, I have this code, but dont know how to fix this errors. So, I need help.
 

I want to use file Txt to control , write line number , write link to file ..... etc

But, when this code run, I can open file Excel, but have errors. 

 

This is my code Auto IT :
Test Read Txt - Xls.au3
 
My file Excel :
New.xls
 
File Txt to control :
Control.txt
 
And this is my code :

#include <IE.au3>
#include <File.au3>
#include <Array.au3>
#include <Date.au3>
#Include <Excel.au3>
#include <Word.au3>
#include <FTPEx.au3>





$partData = FileReadLine ("Control.txt",2)
$oExcelData = _ExcelBookOpen($partData)


$CellName = FileReadLine ("Control.txt",17)
_ExcelWriteCell ($oExcelData,"Name Malibu",4,$CellName)

$CellPhone = FileReadLine ("Control.txt",8)
_ExcelWriteCell ($oExcelData,"0012848299124",4,$CellPhone)

And this is my Errors :

D:\AutoIt3\Include\Excel.au3 (451) : ==> The requested action with this object has failed.:
$oExcel.Activesheet.Cells($sRangeOrRow, $iColumn).Value = $sValue
$oExcel.Activesheet.Cells($sRangeOrRow, $iColumn)^ ERROR
Link to comment
Share on other sites

  • 3 months later...

Hi there!

I have the same problem. I look everywhere without luck for solution.

Today i found a very strange solution. If we want this script to work we must give a fake value to wake up the script

example:

      1. $CellName = FileReadLine ("Control.txt",17) ;your line
        
        $test1 = msgbox(0,"",$CellName,1) ;trick starts
        
        if $test1 = -1 then
        $bla = $CellName +1 -1            ;the wake up trick
        endif                             ;trick ends
        
        _ExcelWriteCell($oExcelData,"Name Malibu",4,$bla) ; not $CellName

        Tell me if is working!!

Edited by gregorkkk
Link to comment
Share on other sites

What exactly are you attempting to do with this line "$bla = $CellName +1 -1"?

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

Link to comment
Share on other sites

as I say "to wake up the variable value"

My script was:

$oExcel = _ExcelBookOpen(@DesktopDir & "\t.xls")
$sLastCell = $oExcel.Application.Selection.SpecialCells($xlCellTypeLastCell).Address(True, True, $xlR1C1)
$var = StringRight($sLastCell,1)
FOR $i = 1 to 10 Step 1
_ExcelWriteCell($oExcel,$i,$i,$var)
Next

But it doesn't work (I am not an expert script writter, but i tried many things)

$oExcel = _ExcelBookOpen(@DesktopDir & "\t.xls")
$sLastCell = $oExcel.Application.Selection.SpecialCells($xlCellTypeLastCell).Address(True, True, $xlR1C1)
$var = StringRight($sLastCell,1)
FileOpen(@DesktopDir & "\test.txt",2)
FileWrite(@DesktopDir & "\test.txt",$var)
$test = FileRead(@DesktopDir & "\test.txt",1)
$test1 = MsgBox(0,"",$test,1)
if $test1 = -1 Then
$bla = $test +1 -1
EndIf
FOR $i = 1 to 10 Step 1
_ExcelWriteCell($oExcel,$i,$i,$bla)
Next

That script with the +1 -1 trick working!! (I don't know why exactly. Maybe you can tell me)

Edited by gregorkkk
Link to comment
Share on other sites

I haven't a clue what you're attempting to do with that line, what it's doing is taking the string returned by FileRead, and then adding 1 to the string (converting the string to a number) and then subtracting 1 from the previous result.

What version of AutoIt are you using, because the updated Excel UDF uses different naming.

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

Link to comment
Share on other sites

I use AutoIt v3.3.6.1

see the comments:

$oExcel = _ExcelBookOpen(@DesktopDir & "\t.xls")

$sLastCell = $oExcel.Application.Selection.SpecialCells($xlCellTypeLastCell).Address(True, True, $xlR1C1) ;this is a trick: How to read the range of t.xls for example "R3C6"

$var = StringRight($sLastCell,1) ;gives me the number of last column for example "6"

FOR $i = 1 to 10 Step 1
_ExcelWriteCell($oExcel,$i,$i,$var) ; here i want to use the value of last column which is "6" into the loop but it doesn't work
Next
 
It not seems logical and I don't know why, but the trick "if" & "msgbox" & "the new variable with +1-1" is working.
Can you try "the above not working script" to make it working?!?
Edited by gregorkkk
Link to comment
Share on other sites

I don't have that version available, it's also 4 years old. You should probably update to a newer or the newest version. The Excel UDF has been vastly improved over that version.

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

Link to comment
Share on other sites

The UDFs can't be combined in a single UDF because the design concept has changed.

The removed functions are only single line functions which became obsolete based on the new design concept or where 90% of the code were used for error checking of the passed parameters.

Please have a look at the wiki how to replace dropped functions.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

"The UDFs can't be combined in a single UDF because the design concept has changed."

I didn't mean to compine the two versions of UDF. I mean-->

With two PC: (first PC) write a part of script to my older autoit version with old UDF excel, compiled to .exe and (second PC): write another part of script and execute the older func to the new version. 

I haven't read yet the wiki how to replace dropped functions, but i will definitely do that. Thanks!!

Link to comment
Share on other sites

Let me know if you encounter any problems.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

×
×
  • Create New...