Need helping opening PCF files

bbcjmr

New Member
Joined
Aug 29, 2019
Messages
2
Hello all, I have this code that searches a directory for word docs and if they exist in the spreadsheet it then copies them to a new folder but recently we have changed from using word docs and now use PDF format but I cant seem to find away to make this script work for PDF files, Does anyone know how to get this code to work with PDF? Thank you!!!

Sub CopyDocs()
Dim fldr As FileDialog
Dim sItem As String
Dim c As Object
Dim Path As String
Dim FName As String
Dim SPath As String
Dim wd As Word.Application
Set wd = CreateObject("word.application")
wd.Visible = False


Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
With fldr
.Title = "Select a Folder"
.AllowMultiSelect = False
If .Show <> -1 Then GoTo NextCode
sItem = .SelectedItems(1)
End With


With ActiveSheet
Lrow = ActiveSheet.Cells(1500, 2).End(xlUp).Row




For Each c In .Range("B2:B" & Lrow)
Path = sItem
FName = Dir(Path & "\*.doc*")
Do
If InStr(FName, c) > 0 And c <> "" Then
On Error Resume Next
MkDir (ThisWorkbook.Path & "" & ActiveSheet.Name)
MkDir (ThisWorkbook.Path & "" & ActiveSheet.Name & "\Review")
On Error Resume Next
If .Cells(c.Row, "L") = "" Then
On Error Resume Next
wd.Documents.Open Filename:=Path & "" & FName
wd.ActiveDocument.SaveAs (ThisWorkbook.Path & "" & ActiveSheet.Name & "\Review" & FName)
wd.ActiveDocument.Close
c.Offset(, 10) = "Moved"
End If
End If
FName = Dir()
Loop Until FName = ""
Next c
End With

NextCode: Exit Sub
wd.Quit
Set fldr = Nothing
Set wd = Nothing
End Sub
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top