Hi all, I am a complete novice with VBA but I am loving the learning curve. I have been searching for ever for a solution to my post but I have been unable to find one. At the moment I have put together the code below that works but the issue with it is that you need to keep selecting the folder and file for each cell in each sheet that you want the attachment to be added to. Is there a way of doing this were I only need to select the folder and file one time and it will then go add the attachment to the specified Sheets and Cells.
My code
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Private Sub CommandButton1_Click()
Call Module22.CommandButton1_Click
Call Module23.CommandButton1_Click
Call Module24.CommandButton1_Click
End Sub[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]
Module 22[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Public Sub CommandButton1_Click()
Application.Goto (ActiveWorkbook.Sheets("Sheet1").Range("C71"))
'Get file path
fpath = Application.GetOpenFilename("All Files,*.*", Title:="Select file")
If LCase(fpath) = "false" Then Exit Sub
'Insert file
ActiveSheet.OLEObjects.Add _
FileName:=fpath, _
Link:=False, _
DisplayAsIcon:=True, _
IconFileName:="excel.exe", _
IconIndex:=0, _
IconLabel:=extractFileName(fpath)
End Sub[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]
Module 23[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Public Sub CommandButton1_Click()
Application.Goto (ActiveWorkbook.Sheets("Sheet2").Range("C71"))
'Get file path
fpath = Application.GetOpenFilename("All Files,*.*", Title:="Select file")
If LCase(fpath) = "false" Then Exit Sub
'Insert file
ActiveSheet.OLEObjects.Add _
FileName:=fpath, _
Link:=False, _
DisplayAsIcon:=True, _
IconFileName:="excel.exe", _
IconIndex:=0, _
IconLabel:=extractFileName(fpath)
End Sub[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]
Module 24[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Public Sub CommandButton1_Click()
Application.Goto (ActiveWorkbook.Sheets("Sheet3").Range("C71"))
'Get file path
fpath = Application.GetOpenFilename("All Files,*.*", Title:="Select file")
If LCase(fpath) = "false" Then Exit Sub
'Insert file
ActiveSheet.OLEObjects.Add _
FileName:=fpath, _
Link:=False, _
DisplayAsIcon:=True, _
IconFileName:="excel.exe", _
IconIndex:=0, _
IconLabel:=extractFileName(fpath)
End Sub[/FONT]
My code
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Private Sub CommandButton1_Click()
Call Module22.CommandButton1_Click
Call Module23.CommandButton1_Click
Call Module24.CommandButton1_Click
End Sub[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]
Module 22[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Public Sub CommandButton1_Click()
Application.Goto (ActiveWorkbook.Sheets("Sheet1").Range("C71"))
'Get file path
fpath = Application.GetOpenFilename("All Files,*.*", Title:="Select file")
If LCase(fpath) = "false" Then Exit Sub
'Insert file
ActiveSheet.OLEObjects.Add _
FileName:=fpath, _
Link:=False, _
DisplayAsIcon:=True, _
IconFileName:="excel.exe", _
IconIndex:=0, _
IconLabel:=extractFileName(fpath)
End Sub[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]
Module 23[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Public Sub CommandButton1_Click()
Application.Goto (ActiveWorkbook.Sheets("Sheet2").Range("C71"))
'Get file path
fpath = Application.GetOpenFilename("All Files,*.*", Title:="Select file")
If LCase(fpath) = "false" Then Exit Sub
'Insert file
ActiveSheet.OLEObjects.Add _
FileName:=fpath, _
Link:=False, _
DisplayAsIcon:=True, _
IconFileName:="excel.exe", _
IconIndex:=0, _
IconLabel:=extractFileName(fpath)
End Sub[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]
Module 24[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]Public Sub CommandButton1_Click()
Application.Goto (ActiveWorkbook.Sheets("Sheet3").Range("C71"))
'Get file path
fpath = Application.GetOpenFilename("All Files,*.*", Title:="Select file")
If LCase(fpath) = "false" Then Exit Sub
'Insert file
ActiveSheet.OLEObjects.Add _
FileName:=fpath, _
Link:=False, _
DisplayAsIcon:=True, _
IconFileName:="excel.exe", _
IconIndex:=0, _
IconLabel:=extractFileName(fpath)
End Sub[/FONT]