473,480 Members | 2,266 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to export data to excel format from Visual basic

7 New Member
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 40747
DPK
16 New Member
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
bimalkumar
7 New Member
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
bimalkumar
7 New Member
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 New Member
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
dedydut
1 New Member
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
1521
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
6807
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
1139
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
1661
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
37960
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
3736
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
5330
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
1337
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
1063
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
3493
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...
0
6912
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7052
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6744
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6981
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5348
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4488
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3000
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1304
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
188
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.