+ Reply to Thread
Results 1 to 3 of 3

VBA code to save workbook with no prompt

  1. #1
    Registered User
    Join Date
    02-04-2022
    Location
    FL
    MS-Off Ver
    Office 365
    Posts
    29

    VBA code to save workbook with no prompt

    I have a macro that converts single pages from a word document to a pdf, and saves them to a folder as "Page1, Page2, etc."

    In between each conversion, I get a popup to Save, Don't Save, or Cancel.

    Is there a way to auto select "Don't Save", so I don't have to select it between each conversion?


    Sub savepdf()
    Dim Counter As Long, Source As Document, Target As Document
    Set Source = ActiveDocument
    Selection.HomeKey Unit:=wdStory
    Pages = Source.BuiltInDocumentProperties(wdPropertyPages)
    Counter = 0
    While Counter < Pages
    Counter = Counter + 1
    DocName = "Page" & Format(Counter) & ".pdf"
    Source.Bookmarks("\Page").Range.Cut
    Set Target = Documents.Add
    Target.Range.Paste
    Target.SaveAs FileName:=DocName, FileFormat:=wdFormatPDF
    Target.Close
    Wend
    End Sub

  2. #2
    Registered User
    Join Date
    05-02-2020
    Location
    Vancouver, Canada
    MS-Off Ver
    Office 2019
    Posts
    68

    Re: VBA code to save workbook with no prompt

    Application.DisplayAlerts = False
    Application.ScreenUpdating = False

    Application.ActiveWorkbook.Close SaveChanges:=True

    Application.DisplayAlerts = True
    Application.ScreenUpdating = True

  3. #3
    Registered User
    Join Date
    02-04-2022
    Location
    FL
    MS-Off Ver
    Office 365
    Posts
    29

    Re: VBA code to save workbook with no prompt

    Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How do I name and prompt to save a new workbook that I created?
    By oddinho2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-17-2013, 03:08 AM
  2. [SOLVED] save without prompt and close the workbook at the same time
    By bta in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-27-2012, 06:43 AM
  3. [SOLVED] Save sheet in new workbook without prompt
    By VBA FTW in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-20-2012, 03:17 PM
  4. Copy entire workbook then prompt 'save as'
    By sgeorge in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-29-2007, 12:10 PM
  5. [SOLVED] How to make Save prompt come up on Excel workbook
    By Sammi in forum Excel General
    Replies: 6
    Last Post: 08-04-2006, 06:15 PM
  6. Replies: 1
    Last Post: 02-24-2006, 10:15 PM
  7. [SOLVED] No save prompt when closing workbook
    By budfrog130 in forum Excel General
    Replies: 0
    Last Post: 12-06-2005, 10:00 AM
  8. Code to open new workbook, prompt for 'save as' name.
    By Mark in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-05-2005, 06:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1