473,385 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how to export data to excel format from Visual basic

hi 2 all,
i m using some txt boxes and few combo box in my form. how do i export the txt box and combobox data to excel sheet directly without using any database.just get the data from txt box and combo box and export it to excel.

while answering pls remember i m not regular VB coder. I just do it for some small application.
pls help me.
Sep 19 '06 #1
5 40737
DPK
16
Dim appxl
Dim Book As Excel.Workbooks
Dim Wsheet As Excel.Worksheet
'Dim RngWSheet As Excel.Range
FileName = "c:\temp\new.xls"
Set appxl = CreateObject("Excel.Application")
Set Book = appxl.Workbooks
Set Wsheet = Book.Add.Worksheets(1)
'Set rngWSheet = Wsheet.Cells
appxl.Visible = True

Wsheet.Cells(1, 1) = combo.Text/text1.text

Wsheet.SaveAs (FileName)
Book.Close
Sep 20 '06 #2
Thanks for ur rply.

Dim appxl
Dim Book As Excel.Workbooks
Dim Wsheet As Excel.Worksheet
'Dim RngWSheet As Excel.Range
FileName = "c:\temp\new.xls"
Set appxl = CreateObject("Excel.Application")
Set Book = appxl.Workbooks
Set Wsheet = Book.Add.Worksheets(1)
'Set rngWSheet = Wsheet.Cells
appxl.Visible = True

Wsheet.Cells(1, 1) = combo.Text/text1.text

Wsheet.SaveAs (FileName)
Book.Close
Sep 20 '06 #3
Thanks for ur rply.
hi,
when i use your code it gives me error "user-defined type not defined". Is there any component to be used for this code.

pls help me
Sep 20 '06 #4
DPK
16
hi,
when i use your code it gives me error "user-defined type not defined". Is there any component to be used for this code.

pls help me

Hi Vimal !

U just have to give it reference of " Microsoft Excel Object Library "
Just check this check Box From Menu -[ Project > reference ].
Sep 22 '06 #5
Hi Vimal !

U just have to give it reference of " Microsoft Excel Object Library "
Just check this check Box From Menu -[ Project > reference ].
Hi DPK, what if i want to add more data in excel... for example,
i have export data from "Database A" in excel file "test.xls"
now i want to export data from "Database B" in the same excel file, without replacing old data. and the result in excel file is "Database A" and "Database B" in one file... how to do that... thanks for your help...
Nov 16 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Peter | last post by:
I manually created a Datatable and now I want to export it to my clients in Excel format. Is there an easy way of doing this?
6
by: harish | last post by:
I want to give a page break when my one of the field change to some different value. I want separte page for different value at run time.
4
by: William Foster | last post by:
Good afternoon all, I am trying to retrieve data from Microsoft Excel files using Microsoft Visual Basic .NET 2003. I want to be able to run this program on machines not running Microsoft...
0
by: campeon | last post by:
Hello,, I don,t understand bery good the visual basic or excel i dowload a good time activities program from a web site the program is like a cronometer whit start button and stop button...
25
wassup
by: wassup | last post by:
Hi all, This my 1st time to get help at forum. So my problem is I have a form with some textbox inside and I want save the data that key in inside textbox to the Excel format that I create and the...
3
by: shivaoct | last post by:
Hi! I am a B.Sc final year student of Pondicherry university. I want any completed simple project using ADO data control in visual basic 6.0. with form design and codings.
4
by: bonkbc | last post by:
hi! how can we take textbox data from a visual basic 6.0 form and write it to an excel worksheet once a command button is clicked? I've gotten very close to completing this on my own, here is...
1
by: Eduard Allen | last post by:
I am a newbie to this site.. Would you help me to know on how to use the Data Report in Visual Basic 6.0 properly? I have my thesis, that's why I need to learn the process on how to use it.
0
by: Galore | last post by:
Hi All, I am a new member. I am trying to run a query (e.g. select * from SybaseTable where SybaseCol = '12') directly from Excel. I am hoping to be able to define the Data Source (define...
2
by: Johnny Wong | last post by:
Hi, I am new to visual basic. In my vb system, there is a dynamic datagrid to represent different reocrds in our database. Today I am gonna export the data to Excel file. I found most examples code...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.