Can't open workbook from vb6 dll 
Author Message
 Can't open workbook from vb6 dll

I have written a vb6 dll that writes some data from SQL to a workbook
file, duplicates any existing formatting for all returned rows and
then prints the workbook as a PDF file. All this works fine in the VB6
runtime environment. I tested from a VB module and stepped through the
code and it all works. Then I wrote an ASP page to call the component.
I then ran through it again in the VB6 runtime. Again, I was able to
step through the code and run it without halting the execution. Since
I figured all was well, I compiled the project as a dll. Now It hangs
forever. Causing such a problem that IIS hangs and I have to restart
my Win2000 workstation each time it gets run. At one point I was able
to get the error "can't open read-only excel file {file name}". (I
can't remember the exact wording because I don't get that error
anymore - it just hangs). It occured to me that it was a permissions
issue. I have given "full control" access to IWAM_{machine name},
IUSER_{machine name} and even the everyone account. Again, no
difference. I have scoured all the groups I can think of looking for
anyone with an answer to the problem. So finnally, I need to post to
see if anyone can help me. Here's the offending code:

When I call this property "Workbook" I am setting a private member
variable to the workbook in order to reference the workbook throughout
the project. I am opening it with "read-only" access as I do not
intend to save any changes to the file.

-----------------------------------------------------------------------
Public Property Let Workbook(ByVal FileName As String)
Dim FSO As Scripting.FileSystemObject

    Set FSO = New Scripting.FileSystemObject

    'check to make sure the specified file exists
    If Not FSO.FileExists(FileName) Then
        Err.Raise 50001, App.Title & ".ExcelPDF.Workbook", "The
specified Workbook file does not exist."
        GoTo CleanUp
    End If

    'open the workbook and set an object reference
    Excel.Workbooks.Open FileName:=FileName, ReadOnly:=True
    Set XLwb = Workbooks.Item(1)

CleanUp:
    Set FSO = Nothing
    Set XL = Nothing
End Property

----------------------------------------------------------------------------

I have also tried explicitly declaring an Excel.Application object
with the same results.
----------------------------------------------------------------
    Dim XL As Excel.Application

    Set XL = New Excel.Application

    XL.Workbooks.Open FileName, , True
--------------------------------------------------------------

Please, if there is anyone that can help I would greatly appreciate
it.



Wed, 21 Apr 2004 07:29:09 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. VB6: Closing a single workbook while leaving the rest open

2. Msgbox while opening excel workbook from VB6

3. VB6 DLLs and Windows 2000 DLLs

4. VB6 / PPT97 - Open Existing PPT File In VB6?

5. can't open w/excel 2000 after saving w/ vb6.0 sp5

6. Access 97 can't open text files after installing VB6

7. Can't see images in Publisher, cans see thumbs in image manager

8. Realtime Linking from one open workbook to another open workbook

9. asp calling a dll to open a workbook

10. Macro to open a workbook, work in that workbook, than close the workbook (saved)


 
Powered by phpBB® Forum Software © phpBB Group