|
-
Sep 25th, 2003, 08:33 PM
#1
Thread Starter
Lively Member
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
-
Sep 25th, 2003, 09:22 PM
#2
Hyperactive Member
Hope this help 
VB Code:
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
Last edited by csar; Sep 25th, 2003 at 09:27 PM.
Don't leave it till tomorrow, Do It Now!
5361726176757468204368616E63686F747361746869656E

-
Sep 25th, 2003, 10:16 PM
#3
Thread Starter
Lively Member
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
-
Sep 25th, 2003, 10:32 PM
#4
Try:
VB Code:
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|