Sub AttachFile()
Dim fn, iName
iName = ThisWorkbook.Name
Sheets("Admin").Range("Z3000").Value = iName
iNum = ExtractNumber(Sheets("Admin").Range("Z3000"), False, False)
Application.ScreenUpdating = False
fn = Application.GetOpenFilename("All Files,*.*", Title:=" Find file to insert")
If FileLen(fn) > 2000000 Then
MsgBox "File exceeds size limit of 2MB, please choose a smaller file!"
GoTo TheEnd
End If
If fn = False Then
MsgBox "No file has been selected, please try again!"
Else
Sheets("Log File").Select
sFullFileName = fn
iPos = InStrRev(sFullFileName, "\", -1, vbTextCompare)
sFileName = iNum & "-" & Right(sFullFileName, Len(sFullFileName) - iPos)
ActiveSheet.OLEObjects.Add FileName:=fn, Link:=False, DisplayAsIcon:=True, _
IconFileName:=sFileName, IconIndex:=9, IconLabel:=sFileName, Left:=50, _
Top:=5, Width:=50, Height:=40
Sheets("Offering ADD").Select
Sheets("Offering ADD").Unprotect
Range("OffAttach").Value = sFileName
Sheets("Offering ADD").Protect
Range("A8").Select
End If
TheEnd:
Application.ScreenUpdating = True
End Sub
Sub AttachImage()
Dim vFile As Variant
Dim iName
iName = ThisWorkbook.Name
Sheets("Admin").Range("Z3000").Value = iName
iNum = ExtractNumber(Sheets("Admin").Range("Z3000"), False, False)
Application.ScreenUpdating = False
vFile = Application.GetOpenFilename("All Files,*.*", Title:=" Find file to insert")
If FileLen(vFile) > 2000000 Then
MsgBox "File exceeds size limit of 2MB, please choose a smaller file!"
GoTo TheEnd
End If
If LCase(vFile) = "false" Then
MsgBox "No file has been selected, please try again!"
Else
Sheets("Log File").Select
sFullFileName = vFile
iPos = InStrRev(sFullFileName, "\", -1, vbTextCompare)
sFileName = iNum & "-" & Right(sFullFileName, Len(sFullFileName) - iPos)
ActiveSheet.OLEObjects.Add FileName:=vFile, Link:=False, DisplayAsIcon:=True, _
IconIndex:=9, IconFileName:=sFileName, IconLabel:=sFileName, Left:=250, _
Top:=5, Width:=100, Height:=30
Sheets("Offering ADD").Select
Sheets("Offering ADD").Unprotect
Range("OffImage").Value = sFileName
Sheets("Offering ADD").Protect
Range("A8").Select
End If
TheEnd:
Application.ScreenUpdating = True
End Sub