?
Solved

Excel Hangs when saving worksheet from .dll

Posted on 2006-03-24
7
Medium Priority
?
1,240 Views
Last Modified: 2008-01-09
Hi Experts.
Here's one thats got me stumped.

I have created a .dll that contains a class that opens, saves, closes excel. The code works on all my other machines except the server i need it to run on. The Server is 2003 all the other machines are XP Pro/WinNT 2K. When the program is executed, it never returns an error other than:

>> Faulting application wscript.exe, version 5.6.0.8827, faulting module unknown, version 0.0.0.0, fault address 0x00000000.

Here is how this is setup.

I have 2 vbs scripts. 1 runs a copy of the code that is in the dll (it works), the other references the .dll and calls the Open Save Close Functions in the .dll (This one hangs on the Save Function.)

'Code for Script 1:
'--------------------------------
msgbox "Opening Excel"
Dim oExcelApp
Set oExcelApp = CreateObject("EXCEL.APPLICATION")
oExcelApp.Visible = False
oExcelApp.AlertBeforeOverwriting = False
oExcelApp.DisplayAlerts = False
msgbox "adding workbook"
oExcelApp.Workbooks.Add
oExcelApp.Worksheets("Sheet2").Delete
oExcelApp.Worksheets("Sheet3").Delete
Set oWs = oExcelApp.ActiveSheet
Set oWb = oExcelApp.ActiveWorkbook
msgbox "Editing Worksheet"
With oWs
    .Range("A:A").ColumnWidth = 10.86
    .Range("B:B").ColumnWidth = 18.14
    .Range("C:C").ColumnWidth = 8.43
    .Range("D:D").ColumnWidth = 9.43
    .Range("E:E").ColumnWidth = 8.57
    .Range("F:F").ColumnWidth = 8.57
    .Range("G:G").ColumnWidth = 9.43
'    .Range("H:H").ColumnWidth = 10.43
'    .Range("I:I").ColumnWidth = 10.43
'    .Range("J:J").ColumnWidth = 13.43
    .Name = "Sheet 1"
    .Cells(1, 1).Value = "'Coname " 
    .Cells(2, 1).Value = "'SSN"
    .Cells(2, 2).Value = "'NAME"
    .Cells(2, 3).Value = "'TYPE"
'    .Cells(2, 4).Value = "'STUDENTS_NAME"
'    .Cells(2, 5).Value = "'STUDENT_SSN"
'    .Cells(2, 6).Value = "'DISB_NO"
    .Cells(2, 4).Value = "'DISB_AMT"
    .Cells(2, 5).Value = "'GNTE_FEE"
    .Cells(2, 6).Value = "'ORIG_FEE"
    .Cells(2, 7).Value = "'NET_AMT"
End With
msgbox "saving xls"
 ows.saveas "c:\test.xls"
closeexcel
msgbox "Done"


Sub CloseExcel()
    ' Terminate and release the Excel objects.

    oExcelApp.Quit
   
End Sub


'Code for Script 2
'-----------------------------------------
Dim otm
set otm = createobject("trafficmonitor.clsExcel")
msgbox "opening Excel"
otm.openexcel
msgbox "Saving Excel Workbook"
otm.saveexcel "c:\test.xls" <---------{HANGS HERE}
msgbox "Closing Excel"
otm.closeexcel
msgbox "Done"

once the application is hung. I have to go into task manager and end excel. THe code in Script 1 is the same code as in the .dll {clsExcel}

Good Luck....
I hope you can Help
0
Comment
Question by:wraith821
  • 4
  • 3
7 Comments
 
LVL 8

Expert Comment

by:Leo Eikelman
ID: 16284280
try saving it to a sub folder on the c:\ driver rather then on the root


see if that works,

Leo
0
 
LVL 8

Expert Comment

by:Leo Eikelman
ID: 16284325
Also, have you tried increasing the Request timeout on the server to see if it is still processing or if it just simply crashed and not exiting?

there was also some issue I dug up with saving excel sheets with IncludeHeaders set.  I don't know if u are using this functionality or not.

Also, doing a bit more reading I found that this may infact be a bug.

Make sure you have the latest versions installed.

Cheers,

Leo

0
 
LVL 8

Author Comment

by:wraith821
ID: 16285705
This is a vb application not a web app. there are no includes and it running under an account with administrative rights.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Accepted Solution

by:
Leo Eikelman earned 2000 total points
ID: 16288449
Are you just saving one worksheet?

cause maybe you can try using the SaveGrid method.

Through reading I found there are lots of bugs people found in the SaveExcel method.

good luck,

Leo
0
 
LVL 8

Author Comment

by:wraith821
ID: 16314452
That didn't work. something is preventing Excel from saving at all.
0
 
LVL 8

Author Comment

by:wraith821
ID: 16314457
run from the .dll that is.
0
 
LVL 8

Author Comment

by:wraith821
ID: 16346976
Well, for all you people wondering... It was my installation of VB6. when the .dll was compiled on my new machine with a new install of vb6, it just didn't work. i have since found other quirks with other compiled exe's and .dlls compiled on this new machine. I recompiled the .dll on my old machine where it was originally created and it works just fine. So.. even though you didn't help me, i'm going to give leikelman all 500 points just because he tried when noone else would.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month13 days, 20 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question