VBA error when upgraded to excel 2013

Access Beginner

Active Member
Joined
Nov 8, 2010
Messages
311
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have the below code which was working at work using Excel 2010. We have upgraded to Office 2013 and it no longer works

Error: Compile Error. Cant find Project or Library

It does highlight this : If Right(varFile, 4) = ".xls" Then

Code:
Sub PropertyName_SAVEAS()
    Sheets("Menu").Select
    Range("I27").Select
    Dim varFile As Variant
    Dim strFileNameDefault As String
    
    On Error Resume Next
    With ActiveCell
        If Not (.Address = "$I$27" And .Parent.Name = "Menu") Then
            MsgBox "Please select the appropriate cell - See Text Source cell I27 on the Menu sheet"
            Exit Sub
        End If
        If .Value = vbNullString Then
            MsgBox "Please enter a value in cell ""I27""."
            Exit Sub
        End If
        varFile = Application.GetSaveAsFilename(InitialFileName:=.Value, _
            FileFilter:=" Excel Workbook (*.xlsx), *.xlsx," & _
            " Excel 97-2003 Workbook (*.xls), *.xls,", _
            FilterIndex:=1)
    End With
    
    If varFile <> False Then
        If Right(varFile, 4) = ".xls" Then
            ActiveWorkbook.SaveAs varFile, _
                FileFormat:=xlExcel8
        Else
            ActiveWorkbook.SaveAs varFile, _
                FileFormat:=xlOpenXMLWorkbook
        End If
    End If
End Sub
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Try in the VB editor clicking Tools-References and if you have any marked MISSING uncheck the checkbox.
 
Upvote 0

Forum statistics

Threads
1,216,380
Messages
6,130,274
Members
449,570
Latest member
TomMacca52

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