Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-04-2018, 08:10 AM
johndrew johndrew is offline I have Error at  File System Object: Cant find object or lib Windows 10 I have Error at  File System Object: Cant find object or lib Office 2010 32bit
Novice
I have Error at  File System Object: Cant find object or lib
 
Join Date: Jul 2018
Posts: 2
johndrew is on a distinguished road
Default I have Error at File System Object: Cant find object or lib

Code:
Sub threePPg()
'
' threePPg Macro
' Macro recorded 3/14/2008
'
    Selection.MoveDown Unit:=wdLine, Count:=1
    Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
    Selection.Rows.Delete
    Selection.TypeBackspace
    Application.DisplayAutoCompleteTips = True
    ActiveDocument.AttachedTemplate.AutoTextEntries("3Ppg").Insert Where:= _
        Selection.Range, RichText:=True
    Selection.TypeBackspace
    ActiveDocument.AttachedTemplate.AutoTextEntries("addmore").Insert Where:= _
        Selection.Range, RichText:=True
    Selection.TypeBackspace
    
    'Variables

Dim FSO As FileSystemObject
   Dim fol As Folder
    Dim pic As File
    Dim tbl As Table
    Dim roe As Row
    Dim cel As Cell
    Dim ish As InlineShape
    Dim pth As New MSComDlg.CommonDialog
    Dim r As Integer
    Dim t As Integer
    Dim objExif As New ExifReader
    Dim txtExifInfo As String
    
        
entry = 0
'Browse to folder
With Application.FileDialog(msoFileDialogFolderPicker)
    .AllowMultiSelect = False
    If .Show = -1 Then
        pname = .SelectedItems(1)
    Else
        MsgBox "You pressed Cancel"
        Exit Sub
    End If
End With

'file path for pictures
    Set FSO = New FileSystemObject
    Set fol = FSO.GetFolder(pname)

'set row 1 as header for each page
    Set tbl = ActiveDocument.Range.Tables(1)
          ActiveDocument.Tables(1).Rows(1).HeadingFormat = True

'FILLING IN TABLE
    For Each pic In fol.Files
        If LCase(Right(pic.Path, 4)) = ".jpg" Or LCase(Right(pic.Path, 5)) = ".jpeg" Then
            'add row and give reference to it
            Set roe = ActiveDocument.Tables(1).Rows.Add
            'ActiveDocument.Tables(1).Rows(entry).Select
            'entry = entry + 1
            'gives reference to cell 1 then adds text
            Set cel = roe.Cells(1)
            cel.Range.Text = pic.Name
            entry = entry + 1
            
            objExif.Load pic.Path
            '
            'FILL IN THE CELL INFORMATION
            '
            'Selection.MoveDown Unit:=wdLine, Count:=4, Extend:=wdExtend
            'Selection.Delete Unit:=wdCharacter, Count:=1
cel.Range.Text = pic.Name & vbCr & objExif.Tag(Model) & vbCr & pic.DateLastModified & vbCr & pic.Size & " Bytes"
             'gives reference to cell 3 then adds pic
              Set cel = roe.Cells(3)
             'add photo
             Set ish = cel.Range.InlineShapes.AddPicture(FileName:=pic.Path, LinkToFile:=False, SaveWithDocument:=True)
             'add hyperlink..."text" would place text as the hyperlink
             Set MyLink = ActiveDocument.Range.Hyperlinks.Add(ish, pic.Name, , , "")
        End If
    Next
    ActiveDocument.Tables(1).Rows(2).Delete

End Sub


Last edited by johndrew; 07-04-2018 at 08:12 AM. Reason: Dim FSO As FileSystemObject
Reply With Quote
  #2  
Old 07-04-2018, 09:08 PM
gmayor's Avatar
gmayor gmayor is offline I have Error at  File System Object: Cant find object or lib Windows 10 I have Error at  File System Object: Cant find object or lib Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Change
Code:
Dim FSO As FileSystemObject
to

Code:
Dim FSO as Object

Change
Code:
Set FSO = New FileSystemObject
to

Code:
Set FSO = CreateObject("Scripting.FileSystemObject")

Note you have some undeclared variables in use and some declared variables that are not used.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 07-05-2018, 08:15 AM
johndrew johndrew is offline I have Error at  File System Object: Cant find object or lib Windows 10 I have Error at  File System Object: Cant find object or lib Office 2010 32bit
Novice
I have Error at  File System Object: Cant find object or lib
 
Join Date: Jul 2018
Posts: 2
johndrew is on a distinguished road
Default

It now says fol=folder
Can't find project or Library
Reply With Quote
  #4  
Old 07-05-2018, 08:46 PM
gmayor's Avatar
gmayor gmayor is offline I have Error at  File System Object: Cant find object or lib Windows 10 I have Error at  File System Object: Cant find object or lib Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

For FSO operations you need to check Microsoft Scripting Runtime in the available object libraries. That provides access to the DLL C:\Windows\SysWOW64\scrrun.dll
https://stackoverflow.com/questions/...in-vba#3236348
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
I have Error at  File System Object: Cant find object or lib Testing for 'Object has been deleted' error Cosmo Word VBA 14 04-04-2018 01:58 PM
Organization Chart Object Changes to Equation Object? jhcoleman53 Drawing and Graphics 0 08-24-2017 07:09 AM
set row object variable error CLoos Excel Programming 6 03-10-2017 04:48 PM
Problem: object library invalid or contains references to object definitions aligahk06 Office 0 08-19-2010 12:29 PM
Could not load this object as this object is not present in your computer k.gaurav Office 0 08-17-2009 09:57 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:50 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft