• Excel Automation issue (A97/XL2002)

    Author
    Topic
    #397993

    Try using dteFileDate = .ActiveCell.Formula instead of dteFileDate = ActiveCell.Formula, and .Quit (just once) instead of .Application.Quit (twice)

    Viewing 3 reply threads
    Author
    Replies
    • #757580

      I am trying to open an Excel application, then a workbook, then get data from the workbook, then close the workbook and then close Excel.

      When my code is done running, Excel still shows in my task list.

      Any ideas what is going on?

      Morgan

      Sub ImportNewReport()
          'Used to import the daily report
          Dim strFileToImport As String
          strFileToImport = "C:Documents and Settingsmerick01.AD" & _
              "DesktopPLP ProjectsToImport1121Daily PLP Team Projects.xls"
          
          'Open the excel report for importing
          
          Dim objXL As Excel.Application
          Set objXL = New Excel.Application
          With objXL
              .Visible = False
              .Workbooks.Open strFileToImport
              .Range("A2").Select
              Dim dteFileDate As Date
              dteFileDate = ActiveCell.Formula
              
              MsgBox dteFileDate
              
              
              
              .Workbooks.Close
              .Application.Quit
              .Application.Quit
          End With
          
          Set objXL = Nothing
      End Sub

      Edited by HansV to break extremely long line that caused scrolling.

    • #757581

      I am trying to open an Excel application, then a workbook, then get data from the workbook, then close the workbook and then close Excel.

      When my code is done running, Excel still shows in my task list.

      Any ideas what is going on?

      Morgan

      Sub ImportNewReport()
          'Used to import the daily report
          Dim strFileToImport As String
          strFileToImport = "C:Documents and Settingsmerick01.AD" & _
              "DesktopPLP ProjectsToImport1121Daily PLP Team Projects.xls"
          
          'Open the excel report for importing
          
          Dim objXL As Excel.Application
          Set objXL = New Excel.Application
          With objXL
              .Visible = False
              .Workbooks.Open strFileToImport
              .Range("A2").Select
              Dim dteFileDate As Date
              dteFileDate = ActiveCell.Formula
              
              MsgBox dteFileDate
              
              
              
              .Workbooks.Close
              .Application.Quit
              .Application.Quit
          End With
          
          Set objXL = Nothing
      End Sub

      Edited by HansV to break extremely long line that caused scrolling.

    • #757594

      OK, what gives?

      I changed .Application.Quit to .Quit and nothing happened.

      I changed ActiveCell.Formula to .ActiveCell.Forumla and now Excel quits as it should….

      Sign me confused!!!

      • #757623

        Shouldn’t it be ObjXL.Quit? I have that in some code of mine that works …

        If not, then I will have to learn something else!

        kiwi44

      • #757624

        Shouldn’t it be ObjXL.Quit? I have that in some code of mine that works …

        If not, then I will have to learn something else!

        kiwi44

    • #757595

      OK, what gives?

      I changed .Application.Quit to .Quit and nothing happened.

      I changed ActiveCell.Formula to .ActiveCell.Forumla and now Excel quits as it should….

      Sign me confused!!!

    Viewing 3 reply threads
    Reply To: Excel Automation issue (A97/XL2002)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: