Consulting

Results 1 to 9 of 9

Thread: Solved: Macro works on my PC but not on another PC

  1. #1
    VBAX Tutor lynnnow's Avatar
    Joined
    Jan 2005
    Location
    Mumbai, Maharashtra, India
    Posts
    299
    Location

    Solved: Macro works on my PC but not on another PC

    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

    [VBA]
    Dates(i) = Format(ActiveCell.Value, "d-mmm")
    [/VBA]

    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.

    Lincoln

  2. #2
    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" ?
    2+2=9 ... (My Arithmetic Is Mental)

  3. #3
    VBAX Tutor lynnnow's Avatar
    Joined
    Jan 2005
    Location
    Mumbai, Maharashtra, India
    Posts
    299
    Location
    Hi,

    This is how it has been initialized in the userform

    [VBA]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
    [/VBA]

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

    Lincoln

  4. #4
    VBAX Tutor lynnnow's Avatar
    Joined
    Jan 2005
    Location
    Mumbai, Maharashtra, India
    Posts
    299
    Location
    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

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    BTW it was the RefEdit that was your problem, not the Dates issue. That may give another problem, but not the missing library error.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    VBAX Tutor lynnnow's Avatar
    Joined
    Jan 2005
    Location
    Mumbai, Maharashtra, India
    Posts
    299
    Location
    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?

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  9. #9
    VBAX Tutor lynnnow's Avatar
    Joined
    Jan 2005
    Location
    Mumbai, Maharashtra, India
    Posts
    299
    Location
    ok. gotcha. thanks for the explanation. Q.E.D.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •