Member Avatar for borgster

Hello,

I'm using the following code in a EXE to open excel with vb6.0 :

Sub Main()
Dim xlapp As Excel.Application
Dim wkbKei As Excel.Workbook
Dim Key As String

    'Check if file exists
    If FExists(App.Path & "\Kei.xls") = True Then
        'Open file
        Key="test"
        Set xlapp = New Excel.Application
        xlapp.UserControl = True
        Set wkbKei = xlapp.Workbooks.Open(App.Path & _
        "Kei.xls", ReadOnly, Password:=Key)
        wkbKei.RunAutoMacros xlAutoOpen
        xlapp.Visible = True
        
        'Manipulate Excel instance
        xlapp.sheets("sheet1").cells(3,3)=1 
        '
        '....
        'COM1 check loop until Excel file is closed
        '.... 
        'Program end
        '
        '
        Set wkbKei = Nothing
        Set xlapp = Nothing
        Key = ""
    End If
End Sub

After the file is openend another module in de EXE file once in a while checks if a device
connected to com1 is still there and set a value somewhere in the excel file until the excel file is closed:

xlapp.sheets("sheet1").cells(3,3)=1

my problem is that the moment the exe file closes i like to reconnect to this excel instance,
i only do not know how..

Can anyone help me?

Borgster

Hi,

I'm facing a similar situation. Although my interaction with Excel is through .NET.

My application is losing the handle to the Excel application when idle for a long time. I'm trying to either reconnect to the existing Excel application or keep pinging every now and then. Not been successful so far. Can you guide me as to how your problem was solved? Thanks,

How to export a picture from Vb to excel

hi,
please tell me how to export a picture from vb to excel.
I'm using mschart to plot a graph and i want that to export to excel.

thanks
guru

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.