ActiveSheet.ExportAsFixedFormat has stopped working

DCESL

New Member
Joined
Sep 30, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi,

I made an invoicing sheet and purchasing sheet (both separate documents) using information from Mr Excel and it has been working for a couple of months with no problem. I am now getting an error message and it will not work anymore. Screen shots etc below, any help would be very much appreciated.

Excel Sheet.jpg
Run Time Error 1004.jpg
Debug.jpg

VBA Code:
Sub NextPurchaseOrder()
Range("J2").Value = Range("J2").Value + 1
Range("B9:E9").ClearContents
Range("A10:E13").ClearContents
Range("H9:K9").ClearContents
Range("G10:K13").ClearContents
Range("A16:A26").ClearContents
Range("B16:H26").ClearContents
Range("I16:I26").ClearContents
Range("J3:K3").ClearContents
Range("B28:G28").ClearContents
Range("C30:G30").ClearContents
Range("H9:K9").ClearContents
End Sub

Sub SavePOWithNewName()
Dim NewFN As Variant
' Copy Purchase Order to a new workbook
ActiveSheet.Copy
NewFN = "C:\Users\ahollings\DC Emergency Systems LTD\DCESL Main Server - Documents\Ashley Hollings\Purchase Orders\POAH" & Range("J2").Value & ".xlsx"
ActiveWorkbook.SaveAs NewFN, FileFormat:=51
ActiveWorkbook.Close
NextPurchaseOrder
End Sub

Sub SavePurchaseOrderAsPDFAndClear()
    Dim NewFN As Variant
    NewFN = "C:\Users\ahollings\DC Emergency Systems LTD\DCESL Main Server - Documents\Ashley Hollings\Purchase Orders\POAH" & Range("J2").Value & ".pdf"
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=NewFN, _
        Quality:=xlQualityStandard, IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, OpenAfterPublish:=False
    Range("J2").Value = Range("J2").Value + 1
    Range("B9:E13").ClearContents
    Range("A10:E13").ClearContents
    Range("H9:K9").ClearContents
    Range("G10:K13").ClearContents
    Range("A16:A26").ClearContents
    Range("B16:H26").ClearContents
    Range("I16:I26").ClearContents
    Range("J3:K3").ClearContents
    Range("B28:G28").ClearContents
    Range("C30:G30").ClearContents
    Range("H9:K9").ClearContents
End Sub
 
Last edited by a moderator:

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Welcome to the Board!

Did you confirm that you don't already have a file open on your computer with that name?

Did you check to see that "C:\Users\ahollings\DC Emergency Systems LTD\DCESL Main Server - Documents\Ashley Hollings\Purchase Orders\" is a valid file path on your computer, and you have the ability to save to that folder?

Did you check to see if you already have a PDF file in that folder with the name you are trying to save the new one to?
 
Upvote 0
I thought that I had but I just rechecked the file path which had changed! Could this be because it is a sharepoint file location?

Thank you for the reply and help. Very new to marcos etc.
 
Upvote 0
You are welcome.

I haven't used Sharepoint yet, so really cannot comment on that. You may want to check with your IT department and inquire why the file path changed.
 
Upvote 0

Forum statistics

Threads
1,214,851
Messages
6,121,931
Members
449,056
Latest member
denissimo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top