+ Reply to Thread
Results 1 to 3 of 3

Compile error with windows 7 and 8.1 VBA commands work in XP.

Hybrid View

Epscan Compile error with windows 7... 11-10-2014, 10:19 PM
Trebor76 Re: Compile error with... 11-10-2014, 10:44 PM
Epscan Re: Compile error with... 11-11-2014, 09:59 AM
  1. #1
    Registered User
    Join Date
    06-17-2009
    Location
    Canada
    MS-Off Ver
    Office 2010
    Posts
    84

    Compile error with windows 7 and 8.1 VBA commands work in XP.

    I have some coding that works well with Excel 2010 on windows XP. Just tried the following code on windows 7 and 8.1. Coming up with Compile error. Can't find project or Library.

    The attached code seems to crash at the Left Command. If I delete that portion then it does not recognize fdlr. Any thoughts how to bring this code to be compatible with Windows 8.1

    Sub Create_Files()
    
    
        Dim FSO As Object
        Dim FromPath As String
        Dim ToPath As String
        Dim NewJobNum  As String
        Dim NewSite  As String
      
    
        NewJobNum = Sheets(1).Cells(8, 4)
        NewSite = Left(Sheets(1).Cells(9, 4), 6)
        
        MsgBox "Select the folder You want new set of files created in"
        
        With Application.FileDialog(msoFileDialogFolderPicker)
            .InitialFileName = Len(ActiveWorkbook.Path) - 1 '.InitialFileName = ActiveWorkbook.Path & "\"
            .Show
        If .SelectedItems.Count = 0 Then GoTo 1
    1        fdlr = .SelectedItems(1)
    
     End With
     
        Unload UserForm1
        
        FromPath = ActiveWorkbook.Path & "\Templates" '<< Change
        ToPath = fdlr & "\" & NewJobNum 'Note: It is not possible to use a folder that exist in ToPath
        
        
        If Right(FromPath, 1) = "\" Then
            FromPath = Left(FromPath, Len(FromPath) - 1)
        End If
    
        If Right(ToPath, 1) = "\" Then
            ToPath = Left(ToPath, Len(ToPath) - 1)
        End If
    
        Set FSO = CreateObject("scripting.filesystemobject")
    
        If FSO.FolderExists(FromPath) = False Then
            MsgBox FromPath & " doesn't exist"
            Exit Sub
        End If
    
        If FSO.FolderExists(ToPath) = True Then
            MsgBox ToPath & " exist, not possible to move to a existing folder"
            Exit Sub
        End If
    
        FSO.CopyFolder Source:=FromPath, Destination:=ToPath
            
        Name ToPath & "\01 Job## Labour xsitex" As ToPath & "\01 Job " & NewJobNum & " Labour " & NewSite
        Name ToPath & "\02 Job## Elect Orders xSitex" As ToPath & "\02 Job " & NewJobNum & " Elect Orders " & NewSite
        Name ToPath & "\03 Job## Elect Used xSitex" As ToPath & "\03 Job " & NewJobNum & " Elect Used " & NewSite
        Name ToPath & "\04 Job## Instr Orders xSitex" As ToPath & "\04 Job " & NewJobNum & " Instr Orders " & NewSite
        Name ToPath & "\05 Job## Instr Used xSitex" As ToPath & "\05 Job " & NewJobNum & " Instr Used " & NewSite
        Name ToPath & "\06 Job## Material Credit Back xSitex" As ToPath & "\06 Job " & NewJobNum & " Material Credit Back " & NewSite
        Name ToPath & "\07 Job## Back Orders" As ToPath & "\07 Job " & " Back Orders " & NewSite
        Name ToPath & "\Labour Tickets V2.0.xlsm" As ToPath & "\" & NewJobNum & " Labour Tickets V2.0.xlsm"
        Name ToPath & "\Elec Material Order V2.0.xlsm" As ToPath & "\" & NewJobNum & " Elec Material Order V2.0.xlsm"
        Name ToPath & "\Elec Material Used V2.0.xlsm" As ToPath & "\" & NewJobNum & " Elec Material Used V2.0.xlsm"
        Name ToPath & "\Inst Material Order V2.0.xlsm" As ToPath & "\" & NewJobNum & " Inst Material Order V2.0.xlsm"
        Name ToPath & "\Inst Material Used V2.0.xlsm" As ToPath & "\" & NewJobNum & " Inst Material Used V2.0.xlsm"
        Name ToPath & "\Material Credit V2.0.xlsm" As ToPath & "\" & NewJobNum & " Material Credit V2.0.xlsm"
        Name ToPath & "\Back Orders V2.0.xlsm" As ToPath & "\" & NewJobNum & " Back Orders V2.0.xlsm"
        
        'This deletes the command button to create a new job
        ActiveSheet.Shapes.Range(Array("CommandButton1")).Select
        Selection.Delete
    
        Application.DisplayAlerts = False
        ActiveWorkbook.SaveAs Filename:= _
            ToPath & "\Setup-Job V2.0.xlsm", _
            FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
       Application.DisplayAlerts = True
    
    End Sub

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Compile error with windows 7 and 8.1 VBA commands work in XP.

    Hi Epscan,

    Remove any references from the Visual Basic Editor (Tools > References) that start with MISSING: and reselect them from the Available References list if necessary.

    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Registered User
    Join Date
    06-17-2009
    Location
    Canada
    MS-Off Ver
    Office 2010
    Posts
    84

    Re: Compile error with windows 7 and 8.1 VBA commands work in XP.

    Hi Robert

    Thankyou!

    Found that I was missing Microsoft calendar control 11.0. Which is interesting because as far as I know I am not using it for anything in my code.

    Unchecked and saved. Everything seems to be working at the moment.
    Will do more testing tomorrow.

    Most of my code has been written for Office 2007.
    I had added the mscomct2.ocx file but if I continue to have problems on future workbooks I will add the mscal.ocx.

    http://answers.microsoft.com/en-us/o...9-e757223ebdde
    Last edited by Epscan; 11-11-2014 at 10:01 AM. Reason: Added Thankyou

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Compile error in hidden moule: The work book
    By praveenkumaranne in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-28-2014, 10:22 AM
  2. [SOLVED] Compile error: Can't find project or library - Windows 7 64 bit
    By onmyway in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-14-2013, 04:15 AM
  3. [SOLVED] Compile Error in Hidden Module and Compile Error: Can't find project or library
    By Taislin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-10-2013, 07:03 PM
  4. [SOLVED] Compile Error: Can't find project or library. Windows vs MAC issue?
    By johnw993 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-04-2013, 05:40 PM
  5. Getting this code to work on MAC (ERROR 68) - works fine on Windows
    By LT1511 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-30-2012, 11:09 PM

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