Results 1 to 4 of 4

Thread: simple Excel Load question

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2004
    Location
    in the heart of the Mediterranean
    Posts
    1,143

    simple Excel Load question

    Hi

    Im trying to load Ms Excel on clicking a picture. It seems to be getting something going on click but the Excel Application never gets loaded. Below is my code which seems okey for me. But sure something is wrong. Can somebody check it out for me pls. The reference is there okey. Ths

    ---------------------------------------------------------
    Private Sub Picture3_Click()
    Dim objExcel As Excel.Application
    Set objExcel = New Excel.Application

    Dim objWorkBook As Excel.Workbook
    Dim objWorkSheet As Excel.WorkSheet

    'make Excel Application load
    objExcel.Visible = True

    End Sub
    -----------------------------------------------------------

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2004
    Location
    in the heart of the Mediterranean
    Posts
    1,143
    Hi,

    Can someone pls tell how

    to check if Excel worksheet is running,

    also later close it.

  3. #3
    Addicted Member
    Join Date
    Aug 2002
    Location
    Luton, UK
    Posts
    178
    Something like this :-

    Code:
        Dim xlApp As Object
        On Error Resume Next
        Set xlApp = GetObject(, "Excel.Application")
        If Err.Number <> 0 Then 'Excel Not Active
            Err.Clear
            Set xlApp = CreateObject("Excel.Application")
        End If
    Regards
    BrianB
    -------------------------------

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2004
    Location
    in the heart of the Mediterranean
    Posts
    1,143
    Hi BrianB,

    Thanks loads for your reply. What I really need is;

    1. I have instructed the user to open Excel.
    2. Then check if he really did the action
    3. After checking close it .

    But I am getting both messages and the excel is not closing. Can you pls tell me why it is doing this. Your urgent reply is very much appreciated. Thanks.

    ---------------------------------------------------------------------------
    Private Sub Command1_Click()

    On Error GoTo IsClosed

    If Not Workbooks("Book1") Is Nothing Then
    MsgBox "Workbook is open"

    Set objExcel = Nothing
    Set objWorkBook = Nothing

    objExcel.Quit
    objWorkBook.Quit

    Else

    IsClosed: MsgBox "Workbook is not open."
    End If

    End Sub
    --------------------------------------------------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width