|
-
February 7th, 2000, 12:13 PM
#1
Open Excel sheet and change value in cells
I will like to open an Excel sheet and change value in cell by code VB.
Thanks
Redg
-
February 7th, 2000, 01:02 PM
#2
Re: Open Excel sheet and change value in cells
public x as Excel.Application
public withevents Book as Excel.Workbook
public Sheet1 as Excel.Worksheet
'in your func
set x = CreateObject("excel.application")
x.Visible = false
set Book = x.Workbooks.Open(strNewDest)
set Sheet1 = Book.Worksheets("Create")
And then you can do anything like in VBA
Or did you mean a recordset. It is possible too
I did it in VC.
-
February 7th, 2000, 05:11 PM
#3
Re: Open Excel sheet and change value in cells
Or, more to the point, if you have an existing spreadsheet
dim xlBook as new Excel.Workbook
set xlBook = getObject(filename as string)
dim xlSheet as Excel.worksheet
set xlSheet = xlBook.Worksheets(1) 'Assuming the info is on sheet 1, could just put in the name as a string in the parentheses.
xlsheet.Cells(1,3).Value = newvalue
Cells(1,3) refers to the 3rd column of the first row. newValue is the value to put into this cell.
This can also be done using the Range object
xlSheet.Range("C1").value = newValue
AS AndyK stated, you can work with all of the features of Excel. The best way to learn of the functionality available is to start Excel and start a VBA session (Tools|Macro|VB Editor), then open a Help window for Visual Basic for Microsoft Excel. Look at the Worksheets and Range or Cells Objects and explore the numerous properties available.
Good Luck...
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
|