Results 1 to 1 of 1

VBA Save As PDF Crashes Excel with no error

Threaded View

  1. #1
    Registered User
    Join Date
    02-04-2021
    Location
    Ohio
    MS-Off Ver
    Office 365
    Posts
    1

    Question VBA Save As PDF Crashes Excel with no error

    Hi,

    I have been using this code to save up to 70 tabs into separate PDFs on a monthly basis for at least a year. There is a "Save to PDF" button on one of the worksheets that runs the macro. I have never had any issues with it but today when I clicked the button to save all the sheets as PDFs, Excel would instantly close and reopen without any errors. I did the Quick Repair option for Office 365 but that didn't solve it. I haven't found anything online to help me. Below is the code. Why does Excel crash without warning or error when it ran just fine last month?

    The code looks at cell J1 on each worksheet and if there is a number "1" there, it will save that tab as a PDF in the directory that the Excel file is currently saved in.

    Option Explicit
    Private Sub SavePDFFuture()
    Application.ScreenUpdating = False
    Dim ws As Worksheet
    For Each ws In ActiveWorkbook.Worksheets
    If ws.Range("J1") = 1 Then

    ws.ExportAsFixedFormat Type:=xlTypePDF, _
    Filename:=ActiveWorkbook.Path & "\" & "PPRFuture_" & ws.Name & " " & Worksheets("Summary").Range("L1"), _
    Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
    End If
    Next ws
    Application.ScreenUpdating = True
    End Sub



    **********UPDATE***********
    I tried one more thing. I changed the save directory to be an actual directory rather than "ActiveWorkbook.Path" and it worked. Why? I have no clue. I am keeping this post here in case other people have the same issue.
    Last edited by excel716; 02-04-2021 at 11:25 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. 2nd Save crashes Excel?
    By Nola111 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-26-2014, 10:29 AM
  2. Excel crashes when i try to save
    By JoshuaSQ in forum Excel General
    Replies: 4
    Last Post: 12-01-2008, 01:44 PM
  3. Excel crashes when trying to save.
    By Ori in forum Excel General
    Replies: 2
    Last Post: 08-20-2006, 07:11 PM
  4. Excel 2000 crashes when I save
    By madthorn in forum Excel General
    Replies: 0
    Last Post: 06-06-2006, 10:55 AM
  5. Excel 2000 crashes when I save
    By madthorn in forum Excel General
    Replies: 0
    Last Post: 06-06-2006, 10:50 AM
  6. Excel crashes when doing Save As
    By edanius in forum Excel General
    Replies: 0
    Last Post: 03-06-2006, 09:05 AM
  7. Excel CRASHES when I try to save
    By betttor77 in forum Excel General
    Replies: 1
    Last Post: 11-09-2005, 03:30 PM

Tags for this Thread

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