Please solve my problem

0 pts.
Tags:
Development
dim xlapp as Excel.Application I declare the above code in the general section of my vb project. but when i try to run my project vb send me a error message like "User-define not define" I got that code from vbcode.com web site. I would like to export FlexGrid data to Excel Sheet.
ASKED: April 3, 2006  3:05 AM
UPDATED: April 4, 2006  2:44 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Use the following syntax to sort out your problem.

Dim exlApp As New Excel.Application
Dim exlSheet As Excel.Worksheet

you are mentioning Excel.application but it should be new excel.application

Hope that will solve your problem.

Rehards,
Chetan Sachdeva

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • ScootMcD
    You must reference the ms excel object library in your project under the project/references menu to make the types available in your project. Microsoft office/excel must be installed in order for you to do this.
    0 pointsBadges:
    report
  • TonyTempio
    This is a copy of a function I use to export a recordset to Excel. Tony Public Function PopulateExcel() As Boolean Dim fldCount As Integer Dim iCol As Integer Dim Msg As String Dim MyFileName As String Dim MySQL As String Dim ExcelApp As Excel.Application Dim ExcelWB As Excel.Workbook Dim X As Boolean On Error Resume Next PopulateExcel = True With frmMain .MousePointer = vbHourglass .stsMsg.SimpleText = "Populating the spreadsheet, please wait." End With DoEvents Set ExcelApp = GetObject(, "Excel.Application") If Err 0 Then If Err = 429 Then ' Excel not running Set ExcelApp = CreateObject("Excel.Application") Err = 0 End If End If MyFileName = "c:MyTempprjSales Analysis.xls" Set ExcelWB = ExcelApp.Workbooks.Open(MyFileName) If Err 0 Then MsgBox Error Set ExcelApp = Nothing GoTo ExitcmdExcel End If If objConn.State adStateOpen Then If Not StartMe() Then PopulateExcel = False GoTo ExitcmdExcel End If End If X = MyQueries(12, MySQL) Set rsRecordset = objConn.Execute(MySQL) If Err 0 Then Msg = "Sorry, couldn't get the data to export." MsgBox Msg, vbCritical + vbOKOnly, "Export Data" PopulateExcel = False GoTo ExitcmdExcel End If ' Copy field names to the first row of the worksheet fldCount = rsRecordset.Fields.Count For iCol = 1 To fldCount ExcelWB.ActiveSheet.Cells(1, iCol).Value = rsRecordset.Fields(iCol - 1).Name Next ' Copy the data from Access DB starting in "A2" ExcelWB.ActiveSheet.Cells(2, 1).CopyFromRecordset rsRecordset If Err 0 Then Msg = "Sorry, couldn't populate the spreadsheet." MsgBox Msg, vbCritical + vbOKOnly, "Export Data" PopulateExcel = False GoTo ExitcmdExcel End If ExitcmdExcel: With frmMain .MousePointer = vbDefault .stsMsg.SimpleText = "The spreadsheet can be found at - " & MyFileName End With DoEvents With ExcelWB .Save .Application.Workbooks.Close End With rsRecordset.Close Set rsRecordset = Nothing Set ExcelWB = Nothing objConn.Close Set objConn = Nothing End Function
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following