Click here to Skip to main content
15,920,513 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionexcel data entry form in vb.net 1.1 Pin
amaneet8-Jun-06 20:24
amaneet8-Jun-06 20:24 
AnswerRe: excel data entry form in vb.net 1.1 [modified] Pin
TheFoZ8-Jun-06 20:40
TheFoZ8-Jun-06 20:40 
GeneralRe: excel data entry form in vb.net 1.1 [modified] Pin
amaneet8-Jun-06 20:45
amaneet8-Jun-06 20:45 
GeneralRe: excel data entry form in vb.net 1.1 [modified] Pin
TheFoZ8-Jun-06 20:50
TheFoZ8-Jun-06 20:50 
GeneralRe: excel data entry form in vb.net 1.1 [modified] Pin
amaneet8-Jun-06 20:57
amaneet8-Jun-06 20:57 
GeneralRe: excel data entry form in vb.net 1.1 [modified] Pin
TheFoZ8-Jun-06 21:04
TheFoZ8-Jun-06 21:04 
GeneralRe: excel data entry form in vb.net 1.1 [modified] Pin
amaneet8-Jun-06 21:12
amaneet8-Jun-06 21:12 
GeneralRe: excel data entry form in vb.net 1.1 [modified] Pin
TheFoZ8-Jun-06 21:54
TheFoZ8-Jun-06 21:54 
No problem.

Right click on References in the solutions explorer and select add reference.
Click on the COM tab and scroll down until you find "Microsoft Excel Object library". if there are a couple selcet the highest version. This will create a reference to the Excel library.

In your code create some variables below:-
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet

Create a variable that hold the path of the spreadsheet you want to open (xlFile)
Set the xl Variables
xlApp = CType(CreateObject("Excel.Application"), Excel.Application)
xlBook = CType(xlApp.Workbooks.Open(xlfile), Excel.Workbook)
xlSheet = CType(xlBook.Worksheets(1), Excel.Worksheet)
This will create the xlspreadsheet in the background. It will not be visable until you say "xlApp.Visible = True"

To put a value into a cell type
xlsheet.Cells(rowNumber, colNumber).Value = ......

To put in a formula Type
xlSheet.Cells(rowNumber, colNumber).Formula = "=A1 + B1" as you would in excel

To delete an entire row
xlSheet.Cells(rowNumber, colnumber).EntireRow.Delete(xlShiftUp)

To delete an entire column
xlSheet.Cells(rowNumber, colNumber).EntireColumn.Delete(xlShiftLeft or xlShiftRight)

To add a worksheet
Dim xlNewSheet as Excel.Worksheet
xlNewSheet = Ctype(xlBook.Worksheets.Add(), Excel.Worksheet)

To change the Name of a worksheet
xlSheet.Name = "My New Sheet"

Is there anything else you would like to do?



QuestionWindows Service Pin
_mubashir8-Jun-06 19:48
_mubashir8-Jun-06 19:48 
AnswerRe: Windows Service Pin
Steve Pullan9-Jun-06 0:53
Steve Pullan9-Jun-06 0:53 
AnswerRe: Windows Service Pin
Dave Kreskowiak9-Jun-06 1:13
mveDave Kreskowiak9-Jun-06 1:13 
Questiondoes vb.net has Method to convert string to unicode and unicode to string? Pin
roitha8-Jun-06 17:32
roitha8-Jun-06 17:32 
AnswerRe: does vb.net has Method to convert string to unicode and unicode to string? Pin
progload8-Jun-06 21:39
progload8-Jun-06 21:39 
AnswerRe: does vb.net has Method to convert string to unicode and unicode to string? Pin
Mekong River8-Jun-06 23:48
Mekong River8-Jun-06 23:48 
QuestionCOPYDATASTRUCT Pin
smokepipes8-Jun-06 12:50
smokepipes8-Jun-06 12:50 
AnswerRe: COPYDATASTRUCT Pin
progload8-Jun-06 15:13
progload8-Jun-06 15:13 
GeneralRe: COPYDATASTRUCT Pin
smokepipes8-Jun-06 22:40
smokepipes8-Jun-06 22:40 
QuestionCustomize Net access? [modified] Pin
Iftikhar Ali8-Jun-06 8:33
Iftikhar Ali8-Jun-06 8:33 
Questionread file Pin
totoblj8-Jun-06 7:50
totoblj8-Jun-06 7:50 
AnswerRe: read file Pin
Dustin Metzgar8-Jun-06 8:11
Dustin Metzgar8-Jun-06 8:11 
QuestionSound?! Pin
md_refay8-Jun-06 6:55
md_refay8-Jun-06 6:55 
AnswerRe: Sound?! [modified] Pin
hmklakmal8-Jun-06 12:19
hmklakmal8-Jun-06 12:19 
QuestionCurrencyManger Pin
md_refay8-Jun-06 6:53
md_refay8-Jun-06 6:53 
QuestionHow do you get .MP3 duration Pin
DaleGraham8-Jun-06 6:08
DaleGraham8-Jun-06 6:08 
AnswerRe: How do you get .MP3 duration Pin
daniel worel11-Jun-06 7:16
daniel worel11-Jun-06 7:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.