Link to home
Start Free TrialLog in
Avatar of GrahamSA
GrahamSAFlag for South Africa

asked on

Compile Error

Hi Experts

I have macro that has been working perfectly, but when I moved the excel file to a new computer and tried to run it I get a compile error.

Here is the line that is in question:

 strDate = Format((Date), "dd MMM yyyy")

The error looks like this.
Compile Error
Cant find project or library

and the date is highlighted blue

Does anyone know why this is suddenly happening?
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

I don't know why, but try this.

strDate = Format((VBA.Date), "dd MMM yyyy")
for me, the formula you have seems to work fine.

have you tried changing the (Date) to Now()

strdate = Format(Now(), "dd MMM yyyy")

Open in new window

SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GrahamSA

ASKER

Cool thanks guys!
I will be back on site in the morning, will let you know...

Thanks so much!
<no points, please>

As Dave points out, having *any* of the references being broken can cause native VBA functions to misbehave like that.  Doesn't just have to be the VBA library :)
Thanks Guys,
Problem is completely solved.

There were missing libraries so I unchecked the tic boxes and BANG!!!