473,385 Members | 1,427 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.

Combine csv file with existing excel file.

My application (I'm using vb.net 2008)generates an excel file with login details and a csv file. How do I add the csv contents to the open excel file? If I can get the hang of this then I can combine six csv file with the ecel file
Expand|Select|Wrap|Line Numbers
  1. rivate Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  2.         Dim oExcel As Object
  3.         Dim oBook As Object
  4.         Dim oSheet As Object
  5.  
  6.         oExcel = CreateObject("Excel.Application")
  7.         oBook = oExcel.Workbooks.Open("J:\vb\RizRandom\RizRandom\UBM.xlsx") ' Add
  8.         oExcel.Visible = True
  9.         oSheet = oBook.Worksheets(1)
  10.  
  11.  
  12.         Dim csvFile As String = Dir("J:\*.csv") ' vb\RizRandom\poo.csv")
  13.  
  14.         Do While csvFile <> ""
  15.             oBook.Open("J:\" & csvFile)
  16.             oBook.Sheets.Add() ' add a new worksheet
  17.             oBook.Sheets(1).cells.copy()
  18.             oBook.Sheets(1).paste()
  19.             oBook.Sheets(1).name = csvFile 'rename the worksheet
  20.             csvFile = Dir()
  21.         Loop
  22.  
  23.         oExcel.DisplayAlerts = vbFalse
  24.         oExcel.AlertBeforeOverwriting = vbFalse
  25.         oBook.SaveAs("J:\vb\RizRandom\RizRandom\TestUBM.xlsx")
  26.         oBook.Close()
  27.  
  28.         oExcel = Nothing
  29.         GC.Collect()
  30.     End Sub
Jan 26 '12 #1
0 1161

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

Similar topics

1
by: mail2atulmehta | last post by:
Hi, I do not know if this is right place for this, but i need some help. I have a text file, whose values are seprated by a delimiter. I want to open this file in excel, ( not import it) . I have...
0
by: Zero | last post by:
how to Overwrite Existing Excel File without prompt and quit?
6
by: jcf378 | last post by:
hello-- i am having trouble figuring out how to export individual records from an Access 2002 Form into a pre-existing Excel spreadsheet, such that the exported record is merely appended to the...
5
by: Aspgm | last post by:
Hi Everyone, I have an Excel file to update on-line using ASP. I could write data to a fresh excel file. But I couldn't find a way to open an existing Excel file and update relevant cells. If...
0
by: jetaw03 | last post by:
guys, i need help in using VB 6.0.can you help me to get a data from an excel file from ms access and put it in ms excel..pls help me guys.. here is the sample of the file in access: sum1 sum2...
5
by: gaya3 | last post by:
Hi all, How to convert text file to excel file in java?? pl any one help me out... is ter any api..??
1
by: egrill | last post by:
I have an Excel file that needs to be updated nightly and sent to a user. I can't find anyway using the existing marcos that would allow me to set a automated command to run the query on a scheduled...
3
by: thanawala27 | last post by:
Hi, I had problems writing in an existing Excel File. There is an excel file with a worksheet. I would like to open this existing Excel file and add another worksheet and write data into it....
32
by: poolboi | last post by:
hi guys, i've read a lot of thread of converting excel data into CSV files. however, i need a perl script to convert CSV file into excel file now, if required modules is needed, it would be...
3
by: premMS143 | last post by:
How to append Data to an existing Excel file? means, I'm using VB as front end & once I exported the data to Excel file & saved it as 'ABC.xls'. Now, the question/doubt is; I addded some more...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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.