VBA Run-Time error '-2147319767 (80028029)'

mcirrone

New Member
Joined
Apr 19, 2022
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
This is a macro used to send an outlook email out with the a two-tabbed file attached. Randomly stopped working, unsure why. The error quotes, "Automation error, invalid forward reference, or reference to uncompiled type."

Any suggestions would be helpful!

Code:

Sub GenerateFuelInventoryReport()
'
' GenerateFuelInventoryReport Macro
' Macro recorded 11/20/2006 by cliggio
' ' CurrentBook = ActiveWorkbook.Name
Sheets(Array("Narrows", "Monthly Accounting")).Select
Sheets("Narrows").Activate Sheets(Array("Narrows", "Monthly Accounting")).Copy
TempBook = ActiveWorkbook.Name
Cells.Select Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False
ActiveSheet.Next.Select
Cells.Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False
'ActiveSheet.Next.Select
'Cells.Select
'Application.CutCopyMode = False
'Selection.Copy
'Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ ' :=False, Transpose:=False
Rows("1:3").Select
Range("A3").Activate
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
Sheets("Narrows").Select
Rows("1:3").Select
Range("A3").Activate
Selection.Delete Shift:=xlUp
'Sheets("Astoria").Select
'Rows("1:3").Select
'Range("A3").Activate
'Selection.Delete Shift:=xlUp
fuelreportname = Range("fuelreportname").Value
Range("B1").Select '
ActiveSheet.Shapes("CommandButton1").Select '
Selection.Delete
Windows(CurrentBook).Activate
Sheets("Oil - GT").Select
Windows(TempBook).Activate
ChDir "L:\Commercial Ops\NYISO\Fuel Ops\Fuel Forecasts\22-02"
ActiveWorkbook.SaveAs Filename:=("L:\Commercial Ops\NYISO\Fuel Ops\Fuel Forecasts\22-02\" & fuelreportname)
Application.Dialogs(xlDialogSendMail).Show arg1:="AstoriaFuelConsumptionReport"

End Sub
 

Attachments

  • Capture.PNG
    Capture.PNG
    6.5 KB · Views: 27

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
The few reports I have seen of this error have generally been able to be resolved by forcing a recompile of the workbook. Try adding a reference in the VB Editor (doesn't really matter what) then compile the project, then remove the reference and recompile and see if that helps.
 
Upvote 0
I was able to solve the problem by re-writing the code. This thread was the most useful I found for doing that. What were three very simple and direct macros are now slightly less smple and direct, but, they appear to work again.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

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