DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Saving data in same file

  1. #1
    Join Date
    Jul 2010

    Saving data in same file

    Hello sir

    I am using u r code it is working, But when I using this code it is creating new file but, I want save data in to same file repeted (but not overwriting) step by step rows

    Option Explicit
    'Add a reference to MS Excel xx.0 Object Library
    Private moApp As Excel.Application
    Private moWB As Excel.Workbook

    Private Sub Form_Load()
    Set moApp = New Excel.Application
    moApp.Visible = False
    End Sub

    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If TypeName(moWB) <> "Nothing" Then
    moWB.Close True, "C:\Text.xls"
    End If
    Set moWB = Nothing
    If TypeName(moApp) <> "Nothing" Then
    End If
    Set moApp = Nothing
    End Sub

    Private Sub Command1_Click()
    Set moWB = moApp.Workbooks.Add
    moApp.Visible = True
    moWB.Sheets("Sheet2").Cells(1, 1).Value = "Added from VB6"
    moWB.Sheets("Sheet1").Cells(1, 1).Value = moWB.Sheets("Sheet2").Cells(1, 1).Value
    End Sub

  2. #2
    Join Date
    Nov 2004
    The best way to find the code you want is to open up an Excel workbook then create and start a new macro recording. After you start the macro recording then open any other existing Excel file you have by going to FILE, OPEN. once that file has also opened you can then stop your macro recording and look at the macros code and see what it does.

Similar Threads

  1. Importing CSV file to data grid
    By software_develo in forum .NET
    Replies: 6
    Last Post: 08-14-2006, 02:50 PM
  2. Copying data from one txt file to another
    By mp_direct in forum VB Classic
    Replies: 1
    Last Post: 11-05-2005, 04:28 PM
  3. load data from .txt file to db2
    By anshulsarabhai in forum Database
    Replies: 0
    Last Post: 05-24-2005, 08:23 AM
  4. Turbo Data: test data generator (
    By Peter Prager (Canam Software) in forum vb.announcements
    Replies: 0
    Last Post: 08-15-2001, 10:48 AM
  5. Replies: 0
    Last Post: 09-02-2000, 08:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center