Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. SaveAs Excel sheet without prompt

SaveAs Excel sheet without prompt

Scheduled Pinned Locked Moved Visual Basic
learning
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    New_Coder
    wrote on last edited by
    #1

    Using VB code I am looking for a way to save an Excel sheet without getting a prompt (in Excel asking if I want to overwrite the file) and close the Excel without user intervention. I have created an Excel.application object (MyExcel), a book object (MyBook) and a sheet object (MySheet) Through code I dump my datagrid data to the Excel Sheet, and save the file to disk using MyBook.SaveAs (save_Path & Save_Name) MyExcel.activeworkbook.close true This works great if the file does not exist, but prompts me to overwrite the file if it does. Any Suggestions would be helpful :doh:

    C 1 Reply Last reply
    0
    • N New_Coder

      Using VB code I am looking for a way to save an Excel sheet without getting a prompt (in Excel asking if I want to overwrite the file) and close the Excel without user intervention. I have created an Excel.application object (MyExcel), a book object (MyBook) and a sheet object (MySheet) Through code I dump my datagrid data to the Excel Sheet, and save the file to disk using MyBook.SaveAs (save_Path & Save_Name) MyExcel.activeworkbook.close true This works great if the file does not exist, but prompts me to overwrite the file if it does. Any Suggestions would be helpful :doh:

      C Offline
      C Offline
      ChandraRam
      wrote on last edited by
      #2

      Two things you can do... - delete file first, if it already exists - set DisplayAlerts to False in MyExcel object HTH

      N 1 Reply Last reply
      0
      • C ChandraRam

        Two things you can do... - delete file first, if it already exists - set DisplayAlerts to False in MyExcel object HTH

        N Offline
        N Offline
        New_Coder
        wrote on last edited by
        #3

        Thanks for the advice "MyCxcel.DisplayAlerts = False" did the trick :-D

        C 1 Reply Last reply
        0
        • N New_Coder

          Thanks for the advice "MyCxcel.DisplayAlerts = False" did the trick :-D

          C Offline
          C Offline
          ChandraRam
          wrote on last edited by
          #4

          New_Coder wrote:

          Thanks for the advice "MyCxcel.DisplayAlerts = False" did the trick

          Glad it worked out for you... you are welcome. :)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups