Solved

writing data into an excel file

Posted on 2003-11-19
3
589 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
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
rajaamirapu earned 75 total points
Comment Utility
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
Comment Utility
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
Comment Utility
wrkBook.SaveAs  YourPath & "\" & filename.xls
wrkBook.Close
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

772 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now