+ Reply to Thread
Results 1 to 5 of 5

Excel VBA Error: "Can't find project or library"

  1. #1
    Registered User
    Join Date
    04-08-2011
    Location
    London
    MS-Off Ver
    O 365
    Posts
    80

    Excel VBA Error: "Can't find project or library"

    I created a vba macro that worked last month but without changing anything, I think, it now is giving me an error at the "Set objFSO". It stops there and says "Can't find project or library". Please help!!


    Sub RateUpdateCopyandPasteLoop()


    Dim DDir As String
    Dim DFormat As String
    Dim i As Long
    Dim PDFFileName As String
    Dim Filename As String
    Dim ActualFilename As String
    Dim strPath As String

    ActualFilename = ActiveSheet.Range("B16")

    DDir = "W:\Derivatives\Swap Documents\Swap Reset Notices (PDF Files)"
    strPath = "W:\Derivatives\Swap Documents\Swap Reset Notices (Excel Files)"

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Const ForWriting = 2
    Set objFolder = objFSO.GetFolder(strPath)

    Application.ScreenUpdating = False

    For Each objFile In objFolder.Files

    If objFSO.GetExtensionName(objFile.Path) = "xls" Then
    Set objWorkbook = Workbooks.Open(objFile.Path)

    ' Takes the updated 1 Month Libor figures and pastes values into Data sheet
    Workbooks.Open Filename:="W:\Derivatives\Swap Documents\1 Month Libor Settings.xls"
    Windows("1 Month Libor Settings.xls").Activate
    Range("A3:B65000").Select
    Selection.Copy
    objWorkbook.Activate
    Sheets("Data").Select
    Range("R2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    Sheets("Swap Reset Notice").Select
    Range("L15").Select
    Selection.Copy
    Sheets("Data").Select
    Range("L1").Select
    Selection.End(xlDown).Select
    Selection.Offset(1, 0).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False

    Workbooks("1 Month Libor Settings.xls").Close Savechanges:=False


    Sheets("Swap Reset Notice").Select
    Range("A2").Select


    DFormat = Format(Date, "m-d-yy") & ".pdf"
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=DDir & "\" & ActiveSheet.Range("B16") & " " & DFormat, Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False


    objWorkbook.Close True 'Save changes
    End If

    Next


    End Sub

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Excel VBA Error: "Can't find project or library"

    you need to use code tags when posting code please

    check tools-references in the vb editor and see what is prefixed with 'MISSING:'
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Registered User
    Join Date
    04-08-2011
    Location
    London
    MS-Off Ver
    O 365
    Posts
    80

    Re: Excel VBA Error: "Can't find project or library"

    MISSING: AdbeAcadIc 1.0 Type Library
    MISSING: PDFMAcad 1.0 Type Library
    MISSING: Adobe 3D Utility 1.0 Type Library

    How would I avoid needing to include the "CreateObject("Scripting.FileSystemObject") portion?

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Excel VBA Error: "Can't find project or library"

    that's not the issue-those three references are. do you use them? if not deselect them and save the file then the code should work

  5. #5
    Registered User
    Join Date
    04-08-2011
    Location
    London
    MS-Off Ver
    O 365
    Posts
    80

    Re: Excel VBA Error: "Can't find project or library"

    That did the trick. Thank you kindly Joseph.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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