CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2001
    Posts
    4

    Need help in closing Excel Application...

    Hi there, i´m new in coding VB, and just started in a Corp programing an application, that between other things, should be able to send data from a grid to a new Excel Book, but, after everything's done, the Excel is still running in the task manager, even after I set the var_Excel to Nothing... I've been trying to resolve this one since Monday, and my time is realy running out. I'de apreciate some help, urgent. Thanks.
    FlipOver


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Need help in closing Excel Application...

    private xlapp as Excel.Application
    private xlWorkbooks as Excel.Workbooks
    private xlWbook as Excel.Workbook
    private xlSheet as Excel.Worksheet

    private Sub Command1_Click()
    Dim intI as Integer

    set xlapp = new Excel.Application
    xlapp.Visible = true
    set xlWorkbooks = xlapp.Workbooks
    xlWorkbooks.Open "c:\myxls.xls" 'your excel

    for Each xlWbook In xlWorkbooks
    for intI = 0 to xlWbook.Worksheets.Count - 1
    set xlSheet = xlWbook.Worksheets(intI + 1)
    Debug.print xlSheet.Name 'you will find more than one sheet here!
    set xlSheet = nothing
    next intI
    next

    'this will close everything

    set xlWbook = nothing
    xlWorkbooks.Close
    set xlWorkbooks = nothing
    xlapp.Quit
    set xlapp = nothing

    End Sub



    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

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

Featured