+ Reply to Thread
Results 1 to 10 of 10

Error:Can't find project or library

  1. #1
    Forum Contributor
    Join Date
    01-06-2004
    Location
    Carbondale CO
    Posts
    245

    Error:Can't find project or library

    Hi,
    I recently copied code out of one VBA project and pasted it into a new project. The code still works fine in the original project, but in the new project I get the Compile Error:Can't find project or library.
    VBA help says this is due to a missing reference and direct me to "Display the References dialog box", but I can't locate this dialog box anywhere. Here is my code and the editor highlights "msg =" in the code. Any help would be greatly appreciated.

    Sub DeleteBlankLastRow_CheckIfBlank()
    Dim Response As Integer
    Dim rngEntryBottomRow As Range

    On Error GoTo ws_exit
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    ActiveSheet.Unprotect ("geekk")
    Set rngEntryBottomRow = Range("Below_Entry_Bottom_Row").Offset(-1)

    'if last detail row is blank, delete one detail row and If not empty
    ' then msg box to explain error and exit sub.
    If Application.WorksheetFunction.CountA(rngEntryBottomRow) > 5 Then
    Msg = MsgBox("You are attempting to Delete a Row that contains User Input. Delete Row Failed", vbOKOnly + vbCritical, "Can Not Delete Row with Information")
    If Response = 1 Or 2 Then Exit Sub

    End If

    If Application.WorksheetFunction.CountA(rngEntryBottomRow) = 5 Then
    With rngEntryBottomRow 'rngI
    .EntireRow.Delete
    End With
    End If

    ActiveSheet.Protect ("geekk"), DrawingObjects:=True, Contents:=True, Scenarios:=True
    Application.ScreenUpdating = True
    ws_exit:
    Application.EnableEvents = True

    End Sub
    Casey

  2. #2
    Jim Thomlinson
    Guest

    RE: Error:Can't find project or library

    Msg is not declared in a Dim satement. I assume that you have Option Explicit
    at the top of this code module (as you should) and that it doe not exist in
    the other module where you copied it from. Change Msg to Response which is
    delcared and you should be good to go. (To be technically correct Response
    should be a long as MsgBox returns a long not an integer but under normal
    circumsatances it makes not practical difference.)
    --
    HTH...

    Jim Thomlinson


    "Casey" wrote:

    >
    > Hi,
    > I recently copied code out of one VBA project and pasted it into a new
    > project. The code still works fine in the original project, but in the
    > new project I get the Compile Error:Can't find project or library.
    > VBA help says this is due to a missing reference and direct me to
    > "Display the References dialog box", but I can't locate this dialog box
    > anywhere. Here is my code and the editor highlights "msg =" in the
    > code. Any help would be greatly appreciated.
    >
    > Sub DeleteBlankLastRow_CheckIfBlank()
    > Dim Response As Integer
    > Dim rngEntryBottomRow As Range
    >
    > On Error GoTo ws_exit
    > Application.EnableEvents = False
    > Application.ScreenUpdating = False
    > ActiveSheet.Unprotect ("geekk")
    > Set rngEntryBottomRow = Range("Below_Entry_Bottom_Row").Offset(-1)
    >
    > 'if last detail row is blank, delete one detail row and If not
    > empty
    > ' then msg box to explain error and exit sub.
    > If Application.WorksheetFunction.CountA(rngEntryBottomRow) > 5
    > Then
    > Msg = MsgBox("You are attempting to Delete a Row that contains
    > User Input. Delete Row Failed", vbOKOnly + vbCritical, "Can Not Delete
    > Row with Information")
    > If Response = 1 Or 2 Then Exit Sub
    >
    > End If
    >
    > If Application.WorksheetFunction.CountA(rngEntryBottomRow) = 5
    > Then
    > With rngEntryBottomRow 'rngI
    > .EntireRow.Delete
    > End With
    > End If
    >
    > ActiveSheet.Protect ("geekk"), DrawingObjects:=True,
    > Contents:=True, Scenarios:=True
    > Application.ScreenUpdating = True
    > ws_exit:
    > Application.EnableEvents = True
    >
    > End Sub
    >
    >
    > --
    > Casey
    >
    >
    > ------------------------------------------------------------------------
    > Casey's Profile: http://www.excelforum.com/member.php...fo&userid=4545
    > View this thread: http://www.excelforum.com/showthread...hreadid=395380
    >
    >


  3. #3
    Bob Phillips
    Guest

    Re: Error:Can't find project or library

    Also take a look at Tools>References in the VBE, and see if any checked
    items do say Missing.

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Jim Thomlinson" <[email protected]> wrote in message
    news:[email protected]...
    > Msg is not declared in a Dim satement. I assume that you have Option

    Explicit
    > at the top of this code module (as you should) and that it doe not exist

    in
    > the other module where you copied it from. Change Msg to Response which is
    > delcared and you should be good to go. (To be technically correct Response
    > should be a long as MsgBox returns a long not an integer but under normal
    > circumsatances it makes not practical difference.)
    > --
    > HTH...
    >
    > Jim Thomlinson
    >
    >
    > "Casey" wrote:
    >
    > >
    > > Hi,
    > > I recently copied code out of one VBA project and pasted it into a new
    > > project. The code still works fine in the original project, but in the
    > > new project I get the Compile Error:Can't find project or library.
    > > VBA help says this is due to a missing reference and direct me to
    > > "Display the References dialog box", but I can't locate this dialog box
    > > anywhere. Here is my code and the editor highlights "msg =" in the
    > > code. Any help would be greatly appreciated.
    > >
    > > Sub DeleteBlankLastRow_CheckIfBlank()
    > > Dim Response As Integer
    > > Dim rngEntryBottomRow As Range
    > >
    > > On Error GoTo ws_exit
    > > Application.EnableEvents = False
    > > Application.ScreenUpdating = False
    > > ActiveSheet.Unprotect ("geekk")
    > > Set rngEntryBottomRow = Range("Below_Entry_Bottom_Row").Offset(-1)
    > >
    > > 'if last detail row is blank, delete one detail row and If not
    > > empty
    > > ' then msg box to explain error and exit sub.
    > > If Application.WorksheetFunction.CountA(rngEntryBottomRow) > 5
    > > Then
    > > Msg = MsgBox("You are attempting to Delete a Row that contains
    > > User Input. Delete Row Failed", vbOKOnly + vbCritical, "Can Not Delete
    > > Row with Information")
    > > If Response = 1 Or 2 Then Exit Sub
    > >
    > > End If
    > >
    > > If Application.WorksheetFunction.CountA(rngEntryBottomRow) = 5
    > > Then
    > > With rngEntryBottomRow 'rngI
    > > .EntireRow.Delete
    > > End With
    > > End If
    > >
    > > ActiveSheet.Protect ("geekk"), DrawingObjects:=True,
    > > Contents:=True, Scenarios:=True
    > > Application.ScreenUpdating = True
    > > ws_exit:
    > > Application.EnableEvents = True
    > >
    > > End Sub
    > >
    > >
    > > --
    > > Casey
    > >
    > >
    > > ------------------------------------------------------------------------
    > > Casey's Profile:

    http://www.excelforum.com/member.php...fo&userid=4545
    > > View this thread:

    http://www.excelforum.com/showthread...hreadid=395380
    > >
    > >




  4. #4
    Forum Contributor
    Join Date
    01-06-2004
    Location
    Carbondale CO
    Posts
    245
    Jim,
    Your clarivoyance (Option Explicit thing) and your code were both right on. Thank you. Follow up if I may. What would be the correct Declaration for Msg?

    Bob,
    Thank you for your input as well. I did go to Tools>References and low and behold, a checked reference to TMPLTNUM.XLA is preceeded by MISSING:.
    What should I do here?

    Thank both of you for your time.

  5. #5
    Jim Thomlinson
    Guest

    Re: Error:Can't find project or library

    I hate to break it to you but the value is never used... Generally it is poor
    code... in this instance this would be the most appropriate code...

    Then
    MsgBox "You are attempting to Delete a Row that contains User Input. " & _
    "Delete Row Failed", vbOKOnly + vbCritical, "Can Not Delete " & _
    "Row with Information"
    Exit Sub

    The statement
    If Response = 1 Or 2 Then Exit Sub
    is evalueated
    If (Response = 1) Or (2) Then Exit Sub
    Where 2 is not 0 and therefore true...

    Here is some code to look at though in case you need to respond to a massage
    box

    if msgbox("Ok?", vbYesNo) = vbyes then
    msgbox "You Pushed Yes"
    else
    Msgbox "You Pushed No"
    end if


    --
    HTH...

    Jim Thomlinson


    "Casey" wrote:

    >
    > Jim,
    > Your clarivoyance (Option Explicit thing) and your code were both right
    > on. Thank you. Follow up if I may. What would be the correct Declaration
    > for Msg?
    >
    > Bob,
    > Thank you for your input as well. I did go to Tools>References and low
    > and behold, a checked reference to TMPLTNUM.XLA is preceeded by
    > MISSING:.
    > What should I do here?
    >
    > Thank both of you for your time.
    >
    >
    > --
    > Casey
    >
    >
    > ------------------------------------------------------------------------
    > Casey's Profile: http://www.excelforum.com/member.php...fo&userid=4545
    > View this thread: http://www.excelforum.com/showthread...hreadid=395380
    >
    >


  6. #6
    Jim Thomlinson
    Guest

    Re: Error:Can't find project or library

    TmpltNum.xla is the template addin. In Excel choose Tools -> Addins ->
    Template Utilities. This will install the addin and clear up the missing
    reference...
    --
    HTH...

    Jim Thomlinson


    "Casey" wrote:

    >
    > Jim,
    > Your clarivoyance (Option Explicit thing) and your code were both right
    > on. Thank you. Follow up if I may. What would be the correct Declaration
    > for Msg?
    >
    > Bob,
    > Thank you for your input as well. I did go to Tools>References and low
    > and behold, a checked reference to TMPLTNUM.XLA is preceeded by
    > MISSING:.
    > What should I do here?
    >
    > Thank both of you for your time.
    >
    >
    > --
    > Casey
    >
    >
    > ------------------------------------------------------------------------
    > Casey's Profile: http://www.excelforum.com/member.php...fo&userid=4545
    > View this thread: http://www.excelforum.com/showthread...hreadid=395380
    >
    >


  7. #7
    Bob Phillips
    Guest

    Re: Error:Can't find project or library

    Casey,

    Uncheck and see if anything goes wrong. My money says it won't.

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Casey" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Jim,
    > Your clarivoyance (Option Explicit thing) and your code were both right
    > on. Thank you. Follow up if I may. What would be the correct Declaration
    > for Msg?
    >
    > Bob,
    > Thank you for your input as well. I did go to Tools>References and low
    > and behold, a checked reference to TMPLTNUM.XLA is preceeded by
    > MISSING:.
    > What should I do here?
    >
    > Thank both of you for your time.
    >
    >
    > --
    > Casey
    >
    >
    > ------------------------------------------------------------------------
    > Casey's Profile:

    http://www.excelforum.com/member.php...fo&userid=4545
    > View this thread: http://www.excelforum.com/showthread...hreadid=395380
    >




  8. #8
    Forum Contributor
    Join Date
    01-06-2004
    Location
    Carbondale CO
    Posts
    245
    Jim,
    Thank you, I have no pride whatsoever in my programming skills, I'm still learning from guys like you. Most of what I do is cobbled together bits and pieces of code gleened from everywhere and I record Macros and clean'em up. Guys like you and Bob are my online mentors. And I turn around and go to the New Users group and try and help them out.
    While I was typing this I just a notification of your reply to my second question. Thank you very much. Have a great weekend.

    PS Did'nt have an opportunity to use your idea or Bob's on the reference problem. Had a need to restart windows and when I got back the reference along with it's MISSING: tag were gone.
    Last edited by Casey; 08-12-2005 at 06:18 PM. Reason: Problem magically disappeared

  9. #9
    Forum Contributor
    Join Date
    01-06-2004
    Location
    Carbondale CO
    Posts
    245
    Bob,
    Got your reply on the reference problem. Between the time I asked the question originally and now; I loaded some new software and had to restart. When I returned to Excel and the editor the reference showing the MISSING: tag was gone through no action on my part. Least that I know about.

    Thanks again for all your help, I think this is about the 5th or 6th time you've saved my bacon.

  10. #10
    Bob Phillips
    Guest

    Re: Error:Can't find project or library

    Casey,

    Just for your satisfaction, check that workbook project now and see if the
    reference to TmpltNum.xla is checked or not. I would venture it is not, and
    from this you can deduce that the workbook was probably started on a machine
    with the addin installed and somehow a reference was made, but when
    transferred to yours, no add-in, reference throws MISSING.

    It is usually safe just to uncheck them. Many times they manifest themselves
    in odd ways, highlighting the Right or Left function, and saying that it
    cannot find the project or library.

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Casey" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Bob,
    > Got your reply on the reference problem. Between the time I asked the
    > question originally and now; I loaded some new software and had to
    > restart. When I returned to Excel and the editor the reference showing
    > the MISSING: tag was gone through no action on my part. Least that I
    > know about.
    >
    > Thanks again for all your help, I think this is about the 5th or 6th
    > time you've saved my bacon.
    >
    >
    > --
    > Casey
    >
    >
    > ------------------------------------------------------------------------
    > Casey's Profile:

    http://www.excelforum.com/member.php...fo&userid=4545
    > View this thread: http://www.excelforum.com/showthread...hreadid=395380
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1