PDA

Click to See Complete Forum and Search --> : Excel ???


tiguy
Sep 25th, 2003, 08:33 PM
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

csar
Sep 25th, 2003, 09:22 PM
Hope this help ;)


Sub Form_Load()
dim oExcelApp as Object,oExcelWK as Object,oExcelSH as Object

Set oExcelapp = CreateObject("Excel.Application")
Set oExcelWK = oExcelApp.Workbooks.Open("ExcelFile.xls")
Set oExcelSH = oExcelWK.Worksheets("Sheet1")

oExcelwk.Activate
'--- read data
text1.text = oExcelSH.Range("E12").value
'oExcelapp.Visible = True ' don't remark if u want to show
oExcelwk.Close False
oExcelapp.Quit
End Sub

Sub Form_Unload()
Set oExcelApp=Nothing
Set oExcelWK=Nothing
Set oExcelSH=Nothing
End Sub

tiguy
Sep 25th, 2003, 10:16 PM
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

Bruce Fox
Sep 25th, 2003, 10:32 PM
Try:

Set oExcelWK = oExcelApp.Workbooks.Open("C:\thkCalcs.xls")