Results 1 to 6 of 6

Thread: (SOLVED) Can't Close Excel Aplication (Range Issue)

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2005
    Location
    Tijuana,Mexico
    Posts
    109

    Resolved (SOLVED) Can't Close Excel Aplication (Range Issue)

    Hi... I have been looking around for this problem, I already found where my problem is but I don't know how to solved.

    I'm sure that my problem has to be with Range (I got this from a VBA but I don't know how to translate it to VB).

    I'm trying to copy some information from Excel to a Flexgrid, but I have to sort this information before... after that I'm closing Excel but that's not happening, in the task manager I can see the process still running and closing only when I close my program.

    vb Code:
    1. Public oApp As Excel.Application
    2. Public oWB As Excel.Workbook
    3. Public osH As Excel.Worksheet
    4. Public oRng As Excel.Range
    5.  
    6.    Set oApp = New Excel.Application
    7.    oApp.Visible = False
    8.    Set oWB = oApp.Workbooks.Open(Archivo)
    9.    Set osH = oWB.Sheets(oWB.Sheets.Count)
    10.    Set oRng = osH.Range("A1")
    11. '*** Now I don't know how to continue...
    12.    oApp.ActiveWorkbook.ActiveSheet.Range(oApp.Selection, oApp.Selection.End(xlDown)).Select
    13.    oApp.Range(oApp.Selection, oApp.Selection.End(xlDown)).Select
    14.    CalcRows = oApp.Selection.Rows.Count
    15.    Clipboard.Clear
    16.    oApp.ActiveWorkbook.ActiveSheet.Range("A1").Select
    17.    oApp.ActiveWorkbook.ActiveSheet.Range(oApp.Selection, oApp.Selection.End(xlDown)).Select
    18.    oApp.ActiveWorkbook.ActiveSheet.Range(oApp.Selection, oApp.Selection.End(xlToRight)).Select
    19.    oApp.Selection.Sort Key1:=Range(Chr(Asc("A") + RosGL - 1) & "2"), Order1:=xlAscending, _
    20.         Key2:=Range(Chr(Asc("A") + RosCoAst - 1) & "2"), Order2:=xlAscending, _
    21.         Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    22.         DataOption1:=xlSortTextAsNumbers, DataOption2:=xlSortTextAsNumbers
    23.    oApp.Selection.Copy
    24.    FG2.Clear
    25.    FG2.Rows = CalcRows
    26.    FG2.Cols = RosCols
    27.    FG2.Redraw = False
    28.    FG2.Row = 0
    29.    FG2.Col = 0
    30.    FG2.ColSel = FG2.Cols - 1
    31.    FG2.RowSel = FG2.Rows - 1
    32.    FG2.Clip = Replace(Clipboard.GetText, vbNewLine, vbCr)
    33.    FG2.Col = 1
    34.    oApp.DisplayAlerts = False
    35.    oWB.Close SaveChanges:=False    '(App.Path + "\Test1.xls")          '"D:\Test.xls"
    36.    Set oWB = Nothing
    37.    LogError = "Archivo cerrado"
    38.    oApp.Quit
    39.    Set oApp = Nothing
    Last edited by G-Hawk; Feb 27th, 2007 at 05:49 PM. Reason: Change VB tags

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