Results 1 to 4 of 4

Thread: Excel ???

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Location
    Ca
    Posts
    124

    Unhappy Excel ???

    This is the code that I have to input some values from an excel file. The problem is that now I want to open the book and go to a specific worksheet.

    Can anyone help?

    Reston

    Private Sub cmdReadXL_Click()

    oXL.Workbooks.Open "C:\ThkCalcs.xls"
    oXL.Visible = False

    txt3 = oXL.Cells.Range("E12", "E12").Value
    txt1 = oXL.Cells.Range("E19", "E19").Value
    txt2 = oXL.Cells.Range("I12", "I12").Value
    txt4 = oXL.Cells.Range("I19", "I19").Value
    txt5 = oXL.Cells.Range("B29", "B29").Value
    txt6 = oXL.Cells.Range("B30", "B30").Value
    oXL.Workbooks.Item("WFLthkCalcs68.xls").Close

    End Sub

  2. #2
    Hyperactive Member csar's Avatar
    Join Date
    Mar 2002
    Location
    Siam
    Posts
    288
    Hope this help

    VB Code:
    1. Sub Form_Load()
    2. dim oExcelApp as Object,oExcelWK as Object,oExcelSH as Object
    3.  
    4.     Set oExcelapp = CreateObject("Excel.Application")
    5.     Set oExcelWK = oExcelApp.Workbooks.Open("ExcelFile.xls")
    6.     Set oExcelSH = oExcelWK.Worksheets("Sheet1")
    7.  
    8.     oExcelwk.Activate
    9.     '--- read data
    10.     text1.text = oExcelSH.Range("E12").value
    11.     'oExcelapp.Visible = True      ' don't remark if u want to show
    12.     oExcelwk.Close False
    13.     oExcelapp.Quit
    14. End Sub
    15.  
    16. Sub Form_Unload()
    17.     Set oExcelApp=Nothing
    18.     Set oExcelWK=Nothing
    19.     Set oExcelSH=Nothing    
    20. End Sub
    Last edited by csar; Sep 25th, 2003 at 09:27 PM.
    Don't leave it till tomorrow, Do It Now!
    5361726176757468204368616E63686F747361746869656E

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2001
    Location
    Ca
    Posts
    124

    Unhappy Excel mistake

    I think i made a mistake.I have an excel worksheet and i need to get to a specific sheets in it

    This is the code that I have to input some values from an excel file. The problem is that now I want to open the sheet and go to a specific worksheet.

    Can anyone help?

    Reston

    This is the code that i just recieved and i have a problem

    Private Sub Form_Load()
    Dim oExcelApp As Object, oExcelWK As Object, oExcelSH As Object

    Set oExcelApp = CreateObject("Excel.Application")

    the problem is here
    >> Set oExcelWK = oExcelApp.Workbooks.Open("thkCalcs.xls")

    Set oExcelSH = oExcelWK.Worksheets("blnchrd")


    oExcelWK.Activate
    '--- read data
    txtC.Text = oExcelSH.Range("E12").Value
    'oExcelapp.Visible = True ' don't remark if u want to show
    oExcelWK.Close False
    oExcelApp.Quit
    End Sub

  4. #4
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Try:
    VB Code:
    1. Set oExcelWK = oExcelApp.Workbooks.Open("[b]C:\[/b]thkCalcs.xls")

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