Hello Everyone,
I wrote below code, this code upload all document from sharedrive into excel based on their naming convention.
However it's applicable for Pdf file only. can you please help me that how can i upload other ext file as well like outlook/word/excel?
Dim folderPath As String, fileName As String
Dim destCell As Range
With Worksheets("ABC")
folderPath = .Range("F7").Value
Set destCell = .Range("G12")
End With
If Right(folderPath, 1) <> "\" Then folderPath = folderPath & "\"
Application.ScreenUpdating = False
fileName = Dir(folderPath & "ABC*.pdf")
Do While fileName <> vbNullString
destCell.Worksheet.OLEObjects.Add _
fileName:=folderPath & fileName, _
Link:=False, _
DisplayAsIcon:=True, _
IconFilename:="C:\windows\Installer\{AC76BA86-1033-F400-7760-000000000005}\_PDFFile.ico", _
IconIndex:=0, _
IconLabel:=fileName, _
Left:=destCell.Left, _
Top:=destCell.Top, _
Width:=150, _
Height:=5
Set destCell = destCell.Offset(, 1)
fileName = Dir
Loop
Application.ScreenUpdating = True
MsgBox "Document Uploaded Successfully..!!"
I wrote below code, this code upload all document from sharedrive into excel based on their naming convention.
However it's applicable for Pdf file only. can you please help me that how can i upload other ext file as well like outlook/word/excel?
Dim folderPath As String, fileName As String
Dim destCell As Range
With Worksheets("ABC")
folderPath = .Range("F7").Value
Set destCell = .Range("G12")
End With
If Right(folderPath, 1) <> "\" Then folderPath = folderPath & "\"
Application.ScreenUpdating = False
fileName = Dir(folderPath & "ABC*.pdf")
Do While fileName <> vbNullString
destCell.Worksheet.OLEObjects.Add _
fileName:=folderPath & fileName, _
Link:=False, _
DisplayAsIcon:=True, _
IconFilename:="C:\windows\Installer\{AC76BA86-1033-F400-7760-000000000005}\_PDFFile.ico", _
IconIndex:=0, _
IconLabel:=fileName, _
Left:=destCell.Left, _
Top:=destCell.Top, _
Width:=150, _
Height:=5
Set destCell = destCell.Offset(, 1)
fileName = Dir
Loop
Application.ScreenUpdating = True
MsgBox "Document Uploaded Successfully..!!"