?
Solved

writing data into an excel file

Posted on 2003-11-19
3
Medium Priority
?
595 Views
Last Modified: 2010-05-01
i need to write some data through my VB code into an existing excel file at a particular cell location. how do i do this?
0
Comment
Question by:RTKVSNL
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
rajaamirapu earned 300 total points
ID: 9785153
Include excel 9 object library.
dim ex as excel.application
Set Ex = New Excel.Application  'intialize excel    
If Not fso.FileExists(txtSourceFolder.Text & "\" & "test.xls") Then
    Set wrkBook = Ex.Workbooks.Add
Else
    Set wrkBook = Ex.Workbooks.Open(txtSourceFolder.Text & "\" & "test.xls")
       
End If

Ex.DisplayAlerts = False
Set wrkSheet = wrkBook.Sheets(2)  'get the current sheet
   
wrkSheet.Name = "xxxx"
'title of the report
'your value here
wrkSheet.Range("C1").ColumnWidth = 20.14
wrkSheet.Range("C1").Value = "xxxx"
You can auto fit also
       
0
 

Author Comment

by:RTKVSNL
ID: 9785203
thanks for the prompt answer. i forgot to mention in my question that at the end i also need to save the file and close it. i am increasing the points of the question so please let me know how to do that
0
 
LVL 5

Expert Comment

by:rajaamirapu
ID: 9785218
wrkBook.SaveAs  YourPath & "\" & filename.xls
wrkBook.Close
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question