3 Replies - 3293 Views - Last Post: 20 April 2010 - 12:49 AM Rate Topic: -----

#1 renmee  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 155
  • Joined: 20-July 09

Runtime error '1004'

Posted 19 April 2010 - 06:04 PM

im having problem with this error "runtime error 1004"

My program runs in powerbuilder to get the data then transfers to excel using VB6 in most of my researches the error is a cause of excel automation. my codes works well, my main problem is the excel generated by my vb retains in the memory "EXCEL.EXE" i cant find a way to take it off the memory when i close the generated excel already. this happens 6 out of 10. i usually end the process then run the code again.

Is This A Good Question/Topic? 0
  • +

Replies To: Runtime error '1004'

#2 bytelogik  Icon User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 212
  • Joined: 06-October 09

Re: Runtime error '1004'

Posted 19 April 2010 - 09:38 PM

Hi renmee,

Are you clearing the EXCEL objects ? example:

Dim exl As Excel.Application
Dim eWorkBook As New Excel.Workbook
'-----------------------------------------------------
Set exl = New Excel.Application
Set eWorkBook = exl.Workbooks.Open(YourExcelFilePath)
'-----------------------------------------------------
'excel I/O code here

'-----------------------------------------------------

eWorkBook.Close
Set exl = Nothing
Set eWorkBook = Nothing
'-----------------------------------------------------
Was This Post Helpful? 0
  • +
  • -

#3 renmee  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 155
  • Joined: 20-July 09

Re: Runtime error '1004'

Posted 19 April 2010 - 11:52 PM

no im not closing it.

i also have chart so should i close that one too?
Was This Post Helpful? 0
  • +
  • -

#4 renmee  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 155
  • Joined: 20-July 09

Re: Runtime error '1004'

Posted 20 April 2010 - 12:49 AM

hi i did try out to add Exlwbk.Close and ExlApp.quit alternately but it didnt work...

Heres a part of it.
Sub Main()

Dim ExlApp 'As Excel.Application
Dim Exlwbk 'As Excel.Workbook
Dim Exlsht 'As Excel.Worksheet
Dim max, min, maj, thick

On errror GoTo ExlError

Set ExlApp = New Excel.Application
Set Exlwbk = ExlApp.Workbooks.Open("C:\QA Reports\temp_subweight2.xls")
Set Exlsht = Exlwbk.Sheets(1)

Exlsht.Activate
'ExlApp.Visible = True

(some more code here)

Exlwbk.Save
ExlApp.Visible = True

Set Exlsht = Nothing
Set Exlwbk = Nothing
Set ExlApp = Nothing

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1