-
Nov 23rd, 2015, 05:30 AM
#1
Thread Starter
New Member
VB6 - WIN 2012 - Excel.applicatin fails - 1004 - Insufficient memory
Hi
I have an appplication wrote with VB6.
I'm working on a Win 2012 R2 server.
This application create an Excel.Application, writes some sheets and saves this file on disk.
Now I would like to schedule this app.
I have created a job using "Task Scheduler" with option "Run only when user is logged on" and everthing works fine.
If I create a job using options "Run whether user is logged on or not" and "Run with highest privileges" process fails and return this error:
1004 - Insufficient memory or not enough space on disk
Do you have any suggestions to solve this issue?
Thank you
Nick
-
Nov 23rd, 2015, 03:26 PM
#2
Re: VB6 - WIN 2012 - Excel.applicatin fails - 1004 - Insufficient memory
as you have given no information at what point the code is failing, hard to make suggestions
it would appear to be an excel error, so an object of excel must have been created, but beyond that no guesses
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Nov 24th, 2015, 01:12 AM
#3
Re: VB6 - WIN 2012 - Excel.applicatin fails - 1004 - Insufficient memory
Office applications are not meant to be used this way.
See Considerations for server-side Automation of Office
Which includes anything running via Task Manager that is not interactive with its logged-on interactive user:
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
So even if you got around your problem you are still juggling dynamite with lit fuses. However your symptoms suggest this is right on target.
The recommended fix is spelled out in the MS KB article linked above under the section Alternatives to server-side Automation. Sadly, this KB article was revised to reflect alternatives based on .Net access to libraries they cobbled up to support the Office XML formats. A VB6 programmer is basically on his own.
Depending on what you need to do in Excel there could be a simple answer or things could get very complex.
-
Nov 24th, 2015, 02:56 AM
#4
Thread Starter
New Member
Re: VB6 - WIN 2012 - Excel.applicatin fails - 1004 - Insufficient memory
Hi Westconn1,
You are rigth. I'm sorry.
Here part of my code:
------------------------
Function Excel_Make()
On Error GoTo Bailerror
Dim oExcelApp As Excel.Application
Dim oWorkbook As Excel.Workbook
Dim oSheet As Excel.Worksheet
....
Set oExcelApp = CreateObject("Excel.Application")
Set oWorkbook = oExcelApp.Workbooks.Add <-----------The ERROR is on this line
.....
Excel_Make = True
Bailexit:
If Not (oRs Is Nothing) Then Set oRs = Nothing
If Not (oSheet Is Nothing) Then Set oSheet = Nothing
If Not (oWorkbook Is Nothing) Then oWorkbook.Close (False)
If Not (oExcelApp Is Nothing) Then oExcelApp.Quit
If Not (oWorkbook Is Nothing) Then Set oWorkbook = Nothing
If Not (oExcelApp Is Nothing) Then Set oExcelApp = Nothing
Exit Function
Bailerror:
Excel_Make = False
Open "C:\PlantLogUser.log" For Append As #1
Write #1, Now & ": Excel_Make - ERROR! " & Err.Number & " " & Err.Description
Close #1
Resume Bailexit
End Function
--------------------
Thank you
Nicola
-
Nov 24th, 2015, 03:07 AM
#5
Thread Starter
New Member
Re: VB6 - WIN 2012 - Excel.applicatin fails - 1004 - Insufficient memory
Hi dilettante,
Thank you for the answer.
Soon I'll read KB article.
But It's very strange that I don't have troubles on win 2003, win 2008 and win 2008 R2 servers, but only in win 2012 R2 (I haven't tried on win 2012) and also when I schedule job with "Run only when user is logged on" option everything works fine.
Regards
NickNick
-
Nov 24th, 2015, 03:08 AM
#6
Thread Starter
New Member
Re: VB6 - WIN 2012 - Excel.applicatin fails - 1004 - Insufficient memory
I forgot, I'm using Excel 2007
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|