Solved

writing data into an excel file

Posted on 2003-11-19
3
593 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 75 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

739 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