Jump to content

Excel problem


Recommended Posts

Hello, I have some problems with opening a excel book and can't find solution...

Here is the code:

Func G_Indeks($FileName)

If $FileName == "" Then
MsgBox(64, "Upozorenje", "Odaberite upisnik za indeksiranje.")
Else

;~  provjera da li postoji indeks za odabranu godinu

$FileName = "I-"&StringRight($FileName,4)
$FilePath = "indeks\"&$FileName&".xls"
$FileNameUP = "K-"&StringRight($FileName,4)
$FilePathUP = "db_upisnik\"&$FileName&".xls"

If FileExists($FilePath) Then

;~   Provjeriti da li je ažuran indeks odabrane godine, ako nije onda ga ažurirati

  MsgBox(0,"","Indeks je ažuriran")
Else

;~   Kreirati indeks za odabranu godinu iz template direktorija i napuniti ga podacima
;~   Kreiranje indeks datoteke

FileCopy("template\indeks.xls", "indeks\")
  FileMove("indeks\indeks.xls", "indeks\"&$FileName&".xls")

;~   Otvaranje datoteke i generiranje podataka
  
Local $oExcelUP = _ExcelBookOpen($FilePathUP)
  Local $oExcel = _ExcelBookOpen($FilePath)

EndIf
EndIf

EndFunc

Excel is 2002 and win xp

error that i get is

>Running:(3.3.8.1):D:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\Korisnik\Desktop\K-upisnik\WIP\K-upisnik.au3"  
D:\Program Files\AutoIt3\Include\Excel.au3 (191) : ==> The requested action with this object has failed.:
If $sPassword = "" And $sWritePassword = "" Then .WorkBooks.Open($sFilePath, Default, $fReadOnly)
If $sPassword = "" And $sWritePassword = "" Then .WorkBooks.Open($sFilePath, Default, $fReadOnly)^ ERROR
->11:42:29 AutoIT3.exe ended.rc:1
>Exit code: 1   Time: 5.836
Link to comment
Share on other sites

Do you get the error with _ExcelBookOpen($FilePathUP) or _ExcelBookOpen($FilePath)?

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

I think you have to specify the absolute path (C:directoryfilename.xls), the UDF has problems with relative paths (filename.xls)

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

Thank you... Here are the changes I made and it's working like a charm.

$FileNameI = "I-"&StringRight($FileName,4)
$FilePathI = @ScriptDir&"indeks"&$FileNameI&".xls"
$FileNameUP = "K-"&StringRight($FileName,4)
$FilePathUP = @ScriptDir&"db_upisnik"&$FileNameUP&".xls"
Link to comment
Share on other sites

;)

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...