Jump to content
Sign in to follow this  
searchresult

Excel problem

Recommended Posts

searchresult

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

Share this post


Link to post
Share on other sites
water

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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
searchresult

With _ExcelBookOpen($FilePath)

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
searchresult

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"

Share this post


Link to post
Share on other sites
water
;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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  

×