Click here to Skip to main content
16,008,075 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: DLL Pin
militiaware11-Jan-06 4:40
militiaware11-Jan-06 4:40 
GeneralRe: DLL Pin
Dave Kreskowiak11-Jan-06 10:54
mveDave Kreskowiak11-Jan-06 10:54 
QuestionInvoking Excel from Access VBA code Pin
john john mackey10-Jan-06 10:35
john john mackey10-Jan-06 10:35 
AnswerRe: Invoking Excel from Access VBA code Pin
Garner T16-Jan-06 13:29
Garner T16-Jan-06 13:29 
GeneralRe: Invoking Excel from Access VBA code Pin
john john mackey16-Jan-06 18:49
john john mackey16-Jan-06 18:49 
QuestionRe: Invoking Excel from Access VBA code Pin
Garner T22-Jan-06 3:35
Garner T22-Jan-06 3:35 
QuestionTab to column 0 in a DataGrid Pin
dptalt10-Jan-06 6:20
dptalt10-Jan-06 6:20 
QuestionDisplay Values in an Excel Worksheet Pin
directred10-Jan-06 5:17
directred10-Jan-06 5:17 
I get the following error "Exception from HRESULT: 0x800A03EC." when I get to this stage of my procedure.

.Range("A" & i.ToString).Value = myRdr("LastName")

Any ideas? I have forwarded the code. Also how to I make sure I have closed EXCEL

Thanks in advance




Private Sub ExcelExtract(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Extract.Click

Dim sProcName As String
Dim sInfoMsg As String
Dim sCriteria As String
Dim i As Double = 3

Dim myRdr As OleDb.OleDbDataReader
Dim excelApp As New Excel.Application
Dim excelBook As Excel.Workbook = excelApp.Workbooks.Add
Dim excelWorksheet As Excel.Worksheet = CType(excelBook.Worksheets(1), Excel.Worksheet)

sProcName = "ExcelExtract_Click"

'Makes Excel invisible to the user until spreadsheet is populated
excelApp.Visible = False

Try
'Populate the Floor Report DataSet used for the Excel spreadsheet
sCriteria = ""
sCriteria = "SELECT LastName, FirstName, Age FROM EmployerTable

Dim myCommand As New OleDb.OleDbCommand(sCriteria, sOleDbConnection)

myRdr = myCommand.ExecuteReader

Catch ex As Exception
sProcName = "ExcelExtract_Click - Populate Report Dataset"
Me.Cursor = System.Windows.Forms.Cursors.Default
ErrorMsg(mcNAME, sProcName, sInfoMsg)
End Try

With excelWorksheet
'Format the Excel cells

.Range("A1..C2").Font.Bold = True
.Range("A1..C2").ColumnWidth = 15

.Range("A1").Value = "REPORT as at " & Now
.Range("A2").Value = "Surname"
.Range("B2").Value = "Forename"
.Range("C2").Value = "Age"

Try
'Place the values into the spreadsheet
Do Until myRdr.Read = False
.Range("A" & i.ToString).Value = myRdr("LastName")
.Range("B" & i.ToString).Value = myRdr("FirstName")
.Range("C" & i.ToString).Value = myRdr("Age")

i = i + 1
Loop

Catch ex As Exception

End Try

End With

excelApp.Visible = True

End Sub



AnswerRe: Display Values in an Excel Worksheet Pin
Dave Kreskowiak10-Jan-06 6:48
mveDave Kreskowiak10-Jan-06 6:48 
GeneralRe: Display Values in an Excel Worksheet Pin
directred10-Jan-06 22:43
directred10-Jan-06 22:43 
GeneralRe: Display Values in an Excel Worksheet Pin
directred10-Jan-06 23:48
directred10-Jan-06 23:48 
GeneralRe: Display Values in an Excel Worksheet Pin
Dave Kreskowiak11-Jan-06 1:14
mveDave Kreskowiak11-Jan-06 1:14 
GeneralRe: Display Values in an Excel Worksheet Pin
directred11-Jan-06 1:30
directred11-Jan-06 1:30 
QuestionNo sorting in DataGrid Pin
dptalt10-Jan-06 4:57
dptalt10-Jan-06 4:57 
AnswerRe: No sorting in DataGrid Pin
Dave Kreskowiak10-Jan-06 6:37
mveDave Kreskowiak10-Jan-06 6:37 
GeneralRe: No sorting in DataGrid Pin
dptalt12-Jan-06 2:33
dptalt12-Jan-06 2:33 
QuestionPopulating a Database from a Dataset Pin
Ria7710-Jan-06 4:14
Ria7710-Jan-06 4:14 
AnswerRe: Populating a Database from a Dataset Pin
Dave Kreskowiak10-Jan-06 6:35
mveDave Kreskowiak10-Jan-06 6:35 
GeneralRe: Populating a Database from a Dataset Pin
Ria7710-Jan-06 8:38
Ria7710-Jan-06 8:38 
GeneralRe: Populating a Database from a Dataset Pin
Dave Kreskowiak10-Jan-06 9:04
mveDave Kreskowiak10-Jan-06 9:04 
Questionhow can implement DTS pakage in vb.net Pin
parvinder sehrawat10-Jan-06 1:53
parvinder sehrawat10-Jan-06 1:53 
AnswerRe: how can implement DTS pakage in vb.net Pin
Dave Kreskowiak10-Jan-06 5:08
mveDave Kreskowiak10-Jan-06 5:08 
GeneralRe: how can implement DTS pakage in vb.net Pin
parvinder sehrawat10-Jan-06 20:45
parvinder sehrawat10-Jan-06 20:45 
GeneralRe: how can implement DTS pakage in vb.net Pin
Dave Kreskowiak11-Jan-06 1:13
mveDave Kreskowiak11-Jan-06 1:13 
QuestionPassing long from ASP to C# method Pin
sauravg2810-Jan-06 0:28
sauravg2810-Jan-06 0:28 

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.