Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 27th, 2004, 01:57 AM
Registered User
 
Join Date: Sep 2004
Location: Bangalore, Karnataka, India.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anjaneekumarcl
Default how to export to excel

Please tell me how export the contents of Listbox to an Excel file using vb on click of the button.

Please Help ASAP.

:(
Reply With Quote
  #2 (permalink)  
Old September 28th, 2004, 04:58 AM
Friend of Wrox
 
Join Date: Sep 2004
Location: New Delhi, Dekhi, India.
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Anantsharma Send a message via Yahoo to Anantsharma
Default

HI,

Add Reference to Microsoft Excel Library whihcever is available

Public Sub WriteToExcel(Byval ExcelFileTOWriteIn as string)
  Dim ExcelApp As Excel.Application
  Dim WS As Excel.Worksheet
  Dim i As Long
  Dim RowNumAs long
  Dim stra As String
  Dim Strb as string
  Set ExcelApp = CreateObject("excel.application")
  ExcelApp.Workbooks.Open (ExcelFileTOWriteIn)
  Set WS = ExcelApp.ActiveWorkbook.Sheets("Sheet1")
  RowNum=1
  For i=0 to List1.listcount-1
      stra="a"+cstr(Rownum)
      WS.Range(stra).value=Trim(List1.list(i))
      RowNum = RowNum + 1
  Next i
  ''Release all the objects u have created....
End Sub

Above code will write all the items from List box to clumn a of excel (a1, a2, a3 etc)

Hope this helps

B. Anant
Reply With Quote
  #3 (permalink)  
Old September 29th, 2004, 04:13 AM
Registered User
 
Join Date: Sep 2004
Location: Bangalore, Karnataka, India.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anjaneekumarcl
Default

thanx Anant

I will try and let you know
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Export to excel moonbreeze Reporting Services 1 November 20th, 2006 08:42 PM
export to excel roy_mm Reporting Services 0 September 2nd, 2006 11:53 PM
Export to Excel using C# lily611 Crystal Reports 2 July 23rd, 2006 10:23 AM
excel export msrnivas Classic ASP Components 0 June 9th, 2004 10:15 PM
excel export msrnivas .NET Web Services 1 March 29th, 2004 03:21 PM



All times are GMT -4. The time now is 05:58 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.