c4mar
asked on
open a existing excel workbook
I am trying to open a existing excel workbook. Inside of it contains 7 sheets and I require to change input the information into cells. Can anyone tell me how to do so????I have use "set wb = getobject("c:\sale.xls") " to open this workbook. It seems like I had open the workbook. However, what ever information I had try to put into the worksheet is not sucessful. Can anyone take me through this???? Thanks
One more thing.
If you need update cell in particulary sheet, you need activate this sheet before or use sheet name directly in Excel object:
xlApp.Worksheets("MySheet" ).Activate
xlApp.Cells(1, 1) = "New Text" ' Changing the value of cell 1,1
or
xlApp.Worksheets("MySheet" ).xlApp.Ce lls(1, 1) = "New Text" ' Changing the value of cell 1,1
If you need update cell in particulary sheet, you need activate this sheet before or use sheet name directly in Excel object:
xlApp.Worksheets("MySheet"
xlApp.Cells(1, 1) = "New Text" ' Changing the value of cell 1,1
or
xlApp.Worksheets("MySheet"
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
I have a form with just 1 command buttons. The button opens a excel document, prints the value from cell 1,1 and then changes the value of cell 1,1.
When you are done with your excel object call the xlApp.Quit method and then set your xlApp object to nothing to free up the resource.
Dim xlApp As Object
Private Sub Command1_Click()
Set xlApp = CreateObject("excel.applic
xlApp.Visible = True
xlApp.workbooks.Open "C:\My Documents\CarLoc.xls"
Print xlApp.Cells(1, 1) ' Printing the value of cell 1,1
xlApp.Cells(1, 1) = "New Text" ' Changing the value of cell 1,1
End Sub