Excel Hangs when saving worksheet from .dll

Posted on 2006-03-24
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, faulting module unknown, version, 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"
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"
msgbox "Done"

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

End Sub

'Code for Script 2
Dim otm
set otm = createobject("trafficmonitor.clsExcel")
msgbox "opening Excel"
msgbox "Saving Excel Workbook"
otm.saveexcel "c:\test.xls" <---------{HANGS HERE}
msgbox "Closing Excel"
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
Question by:wraith821
    LVL 8

    Expert Comment

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

    see if that works,

    LVL 8

    Expert Comment

    by:Leo Eikelman
    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.



    LVL 8

    Author Comment

    This is a vb application not a web app. there are no includes and it running under an account with administrative rights.
    LVL 8

    Accepted Solution

    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,

    LVL 8

    Author Comment

    That didn't work. something is preventing Excel from saving at all.
    LVL 8

    Author Comment

    run from the .dll that is.
    LVL 8

    Author Comment

    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.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
    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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now