Results 1 to 2 of 2
  1. #1
    tylerg11 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    200

    Write data to Excel

    Hello,



    I have some variables in Access that I would simply like to write to specific cells in an excel spreadsheet and save. I would like it to not prompt before it overwrites the previous file with the same name, and not open after it's saved. What code do I need to do this? Currently it saves out a new excel sheet, but it prompts before overwriting the one with the same name, and it opens the file after the save.

    Here is what I have now:

    Code:
    Dim newExcelApp As excel.Application
    Dim newWbk As excel.Workbook
    Dim newWkSheet As excel.Worksheet
    
    Set newExcelApp = excel.Application
    newExcelApp.Visible = True
    
    Set newWbk = newExcelApp.Workbooks.Add
    Set newWkSheet = newWbk.Worksheets(1)
    
    newWkSheet.Cells(1, 1).value = DataVariable
    newWkSheet.Cells(2, 1).value = DataVariable
    
    
    newWkSheet.SaveAs (FilePath)

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 11
    Last Post: 06-16-2014, 08:52 AM
  2. Replies: 3
    Last Post: 10-02-2012, 02:07 AM
  3. Replies: 9
    Last Post: 05-30-2011, 05:43 PM
  4. Write excel expression in access
    By ktmchugh in forum Queries
    Replies: 0
    Last Post: 07-01-2009, 02:47 PM
  5. Parse a File from a Directory and write data to table
    By galahad in forum Database Design
    Replies: 0
    Last Post: 04-23-2009, 08:38 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums