PDA

View Full Version : Solved: Macro works on my PC but not on another PC



lynnnow
01-23-2008, 11:33 PM
Hi,

I've got a simple code that works beautifully on my PC but it throws a compile error "Can't find project or library" when I pass the following code


Dates(i) = Format(ActiveCell.Value, "d-mmm")


It highlights the Format word here. I may have libraries enabled on my PC, but how do I initialize these libraries on other PCs through my code. I get bad feedback that my macros don't work on others' PCs and this downs my spirit a bit.:(

Please help.:help

Lincoln

unmarkedhelicopter
01-24-2008, 02:35 AM
Format is a standard VBA function, it should just be there ...

My question is 'what is "Dates(i)" ?' how is it declared and what is "i" ?

lynnnow
01-24-2008, 02:42 AM
Hi,

This is how it has been initialized in the userform

Private Sub UserForm_Initialize()
Dim Dates(31)
Dim i As Integer
Range("C4").Activate
i = 0

Do While Not IsEmpty(ActiveCell.Value)
Dates(i) = Format(ActiveCell.Value, "d-mmm")
ActiveCell.Offset(0, 1).Activate
i = i + 1
Loop

ComboBox1.List() = Dates

CommandButton1.Caption = "Search Database"
CommandButton2.Caption = "Create mail and close form"
Frame1.Caption = "Attendance Mailer Generator"
UserForm1.Caption = "...::: Lynx's Corner :::..."

Range("A1").Activate
Label1.Caption = ""
Label1.Font.Size = 14
Label1.Font.Bold = True
End Sub


I tried running the code on other machines also and it displayed the same error.

Lincoln

lynnnow
01-24-2008, 02:54 AM
Hey,

Got this code to work. It didn't work coz I hadn't initialized the variable in the first place. I have initialized the variables and the code is working fine on all the PCs I tested it on.

Thanks for the pointer Unmarked

Also, there was a RefEdit.dll library that was missing on one PC. I checked the physical location and it was there, but still it said that it was missing. Any views on this?

Regards,

Lincoln

Bob Phillips
01-24-2008, 04:36 AM
It is probably a different version. If you use RefEdit in your project, find the latest version and reference this. If you don't, just uncheck and remove it from your original project code.

This is why you should ALWAYS develop your code on the lowest deployment paltform. This is not foolproof though because of the many add-ons that can crop up, but it is the safest way.

Bob Phillips
01-24-2008, 04:38 AM
BTW it was the RefEdit that was your problem, not the Dates issue. That may give another problem, but not the missing library error.

lynnnow
01-24-2008, 04:45 AM
Re RefEdit not being available:

The macro was developed on my PC and then deployed to the original file on the PC which displayed the error. It didn't display any runtime errors while I executed the code, and, however, there is no RefEdit used on my userform, then why this bug, or is it a bug?

Bob Phillips
01-24-2008, 04:49 AM
You may not be using RefEdit, but it is referenced in your project. The target machine does not have that version of RefEdit, so it throws a missing library.

It may not be ideal, but no it is not a bug within the context of how it works.

lynnnow
01-24-2008, 04:51 AM
ok. gotcha. thanks for the explanation. Q.E.D.