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



## mcirrone (Apr 19, 2022)

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


----------



## andro02351 (Dec 14, 2022)

Did you ever solve this problem? Did just go away?


----------



## RoryA (Dec 14, 2022)

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.


----------



## andro02351 (Dec 14, 2022)

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.


----------

