Jump to content

Recommended Posts

Posted

Hello, I write an script but not working good.

open and close a excel workbook multiple times whith _Excel_Open() - _Excel_BookOpen() - _Excel_BookClose() - _Excel_Close() . It runs good, but in a determinate moment the script make an error like "the requested action with this object has failed" in $oworkbook^ERROR. The variables are ok.

I don't know whats the problem.

someone can help me?

  • 2 months later...
Posted

Sorry Junkew, i don't see your answer.

after _Excel_BookClose() - _Excel_Close() already exist an excel open with no name and no sheets. I don't know if these could be the cause.

  • Moderators
Posted

@jaume as has already been stated, it is exceedingly difficult to help you fix a script you won't show anyone. Please see this post (it even says "Please read before posting" in the title) for how to correctly ask questions on the forum.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted

I think the problem is in these part of code, because if  I don't need create a new workbook, it works correcly. I need to force to close excel because _Excel_Close ($melapela) don't close it.

Local $melapela = _Excel_Open()

If FileExists($fitxerabuscar) Then

....

Else

   Local $melapelacte = _Excel_BookNew($melapela,2) 
   Sleep(1500)
   $melapelacte.Sheets(1).Name="Informe" 
   $melapelacte.Sheets(2).Name=$nomfulla 
   $melapelacte.Sheets($nomfulla).Activate 
   $melapelacte.Activesheet.Columns("A:D").ColumnWidth=4
   $melapelacte.Activesheet.Columns("E").ColumnWidth=40
   _Excel_RangeWrite($melapelacte,$melapelacte.Activesheet,"TOTAL","F1",True)

.....

EndIf

....

_Excel_BookSaveAs($melapelacte,$fitxerabuscar,$xlExcel8,True) 

_Excel_BookClose ($melapelacte) 
_Excel_Close ($melapela)

 

IF WinExists("Excel") Then ;si s'obre l'excel, el tanca
      WinActivate("Excel")
      Sleep(500)
      WinSetState("Excel", "", @SW_MAXIMIZE)
      Sleep(500)
      MouseClick("Left",1342,13,1) ;aceptar
      Sleep(500)

   Endif

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
×
×
  • Create New...