Run Time error -2147024773 (8007007b)

josros60

Well-known Member
Joined
Jun 27, 2010
Messages
779
Office Version
  1. 365
Hi,

have following code giving the error 2147024773 (8007007b) and highlighting this line in the code:

VBA Code:
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:=NewFN, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False

complete code:

VBA Code:
Sub SaveInvoiceBothWaysAndClear()
    Dim NewFN As Variant
    Call posttoregister
    ' Create the PDF First
    NewFN = "C:\Users\jose.rossi\Desktop\Excel Files\Contras\West Telecom\RHICHOM NETWORKS" & Range("A78").Value & ".pdf"
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:=NewFN, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
    'Next, Save the Excel File
    ActiveSheet.Copy
    NewFN = "C:\Users\jose.rossi\Desktop\Excel Files\Contras\West Telecom\RHICHOM NETWORKS" & Range("A78").Value & ".xlsx"
    ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
    ActiveWorkbook.Close
    ' Increment the invoice number
    Range("K2").Value = Range("K2").Value + 1
    ' Clear out the invoice fields
    Range("C8:C10").ClearContents
    Range("A16:K20").ClearContents
   
End Sub

Another thing happening if disable that line just to save as excel file giving the error 1004 and highlight this line:

VBA Code:
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook

thank you
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
What is in Range("A78").Value and does it contain any invalid characters for a file name? A cursory search for that error code uncovers that is usually the issue for this error code.
 
Upvote 0
Hi,

is a text formula in that cell want it to be part of the file name.

VBA Code:
="Contra"&" # "&K2&"  in the amount of USD "&TEXT(CONTRA!$C$23,"$#,##0.00")&", "&TEXT(CONTRA!$J$26,"MMM-DD-YYYY")&" for "&C10&""""
 
Upvote 0
Hi,

is a text formula in that cell want it to be part of the file name.

VBA Code:
="Contra"&" # "&K2&"  in the amount of USD "&TEXT(CONTRA!$C$23,"$#,##0.00")&", "&TEXT(CONTRA!$J$26,"MMM-DD-YYYY")&" for "&C10&""""

Sorry I dont think I was clear enough. I meant to ask what are some examples that the formula would evaluate to.
 
Upvote 0
The formula result is this:

"CONTRA-RHICOM NETWORKS # 2256 USD $2,500.00, Jun-18-2021 for (JUNE 2021)"

thank you
 
Upvote 0
Well that's a valid filename, so that's not the issue. You should obviously have permission to save in the folder because it's on your desktop, and based on your code above NewFN should be well under the windows max filename length. I'm also assuming a file with that same name is not open when you are trying to save it.

If you add Debug.Print NewFN to your code, what is the output? I suspect you might be missing a "\" at the end of your RHICHOM NETWORKS folder.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,620
Messages
6,120,559
Members
448,970
Latest member
kennimack

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