The code below will go into a directory called cut_sheets and delete any existing pdf files and re-populate with the new selection of hyperlinked pdf files. is it possible to skip over or rename any existing pdf files and only add any new hyperlinked pdf files?
Any Help Appreciated......
Option Explicit
Public Sub Gartner_Get_Hyperlink_Main()
Dim objBlock As AcadBlockReference
Dim objEnt As AcadEntity
Dim colHyps As AcadHyperlinks
Dim fso As FileSystemObject
Set fso = New FileSystemObject
If Len(Dir(ThisDrawing.Path & "\Cut Sheets\*.pdf")) <> 0 Then ' Checks to see if there are any PDFs in CURRENT_Project\Cut Sheets\
fso.DeleteFile ThisDrawing.Path & "\Cut Sheets\*.pdf", True ' If there are, delete them
could i rename any existing files or skip over without deleting them and only add only new .pdf's ?
End If
For Each objEnt In ThisDrawing.ModelSpace
If TypeOf objEnt Is AcadBlockReference Then
Set objBlock = objEnt
Set colHyps = objBlock.Hyperlinks
On Error Resume Next ' In case we encounter any blocks that DON'T have hyperlinks
fso.CopyFile colHyps.Item(0).URL, ThisDrawing.Path & "\Cut Sheets\", True ' The TRUE option will automatically overwrite any existing files with the same name
End If
Next objEnt
Set fso = Nothing
End Sub