Results 1 to 2 of 2

Thread: Excel won't release database

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2010
    Posts
    80

    Excel won't release database

    Can someone look at this code and tell me why it won't release the database after it fills the flexgrid and I close excel. I have tried everything.
    vb Code:
    1. Dim xapp    As Excel.Application
    2. Dim xsheet As Excel.Worksheet
    3. Dim xlWB        As Excel.Workbook
    4.        
    5.     Set xapp = New Excel.Application
    6.     Set xlWB = xapp.Workbooks.Open("C:\Program Files\Denali\Databases\Databasesloc.xls")
    7.     Excel.Application.Visible = False
    8.     Clipboard.Clear
    9.     Set xsheet = xapp.Worksheets(1)
    10.    
    11.     With xsheet
    12.     .UsedRange.Copy
    13.     End With
    14.        
    15.     With MSFlexGrid1
    16.         .Redraw = False    
    17.         .row = 0            
    18.         .Col = 0
    19.         .RowSel = .Rows - 1
    20.         .ColSel = .cols - 1
    21.         .clip = Replace(Clipboard.GetText, vbNewLine, vbCr)
    22.         .Col = 1          
    23.         .Redraw = True        
    24.     End With
    25.  
    26.        xapp.DisplayAlerts = False
    27.        Clipboard.Clear
    28.        MSFlexGrid1.Rows =xapp.ActiveWorkbook.ActiveSheet.UsedRange.Rows.count + 1
    29.  
    30.    'Trying to close Excel here
    31.  
    32.    Set xsheet = Nothing
    33.    xlWB.Close SaveChanges:=False
    34.    Set xlWB = Nothing
    35.     xapp.Quit
    36.     Set xapp = Nothing
    37.     Excel.Application.Quit
    Last edited by Hack; Jul 16th, 2010 at 05:59 AM. Reason: Added Highlight Tags

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Excel won't release database

    See Post #11 in this most excellent tutorial.

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