Share via

VBA code coming back with Compile error

Anonymous
2015-09-08T01:35:29+00:00

Dear All,

I am trying to run a VBA macro that saves a file with the .xlsm extension.  When I run the macro (via a command button: SAVE FILE), I get the following Compileerror:

Can't find project or library

When I press OK to view the debug screen, I can see that the first Format instruction in the following code highlighted:

Sub SAVE_FILE()

 Dim vFile

  vFile = Application.GetSaveAsFilename(Format(Worksheets("Price Desk Form").Range("A6").Value) & " - Price Desk Worksheet" & Format(Date, " - mmmm yyyy"), "Excel files (*.xlsm),*.xlsm")

  If TypeName(vFile) = "Boolean" Then Exit Sub ' user cancelled

  ActiveWorkbook.SaveAs vFile, FileFormat:=52

End Sub

Now, I have been running this VBA for several years now.  The only difference is that I now have a new computer.  Both the computers use Excel 2010 in Windows 7.  So, I am not sure why I am now getting this message.  The same .xlsm file works in my co-workers' computers.

I have a series of macros in this file and so am not sure if the code shown above is the initial trigger for the compile error.  I think it is as this particular macro is the first set of instruction that I would do - i.e. save the file as a .xlsm.

Hope you can provide me with some tips.  Thank you.

Regards,

Sam.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2015-09-08T05:08:34+00:00

    Hi,

    This issue might be occurred due to missing library. Have u checked the same at Tools>ReferencesIn VBA.

    Was this answer helpful?

    0 comments No comments