H
Huber57
Hello all:
I have searched high and low for an answer and I am stumped.
I have a table with two columns. In column A, I have the filename of an
image that I would like to insert into column B. There are over 1,000. Is
there any way to write a macro to insert all of them into Column B based on
the information in Column A? I found this macro for excel but I don't know
if it could be used as a starting point for Word.
Sub ABCD()
Dim pic As Picture
Dim sPath As String, sName As String
Range("B2").Select
sPath = "C:\Graphics\"
sName = Range("A2").Value
If LCase(Right(sName, 4)) <> ".png" Then
sName = sName & ".png"
End If
If Dir(sPath & sName) <> "" Then
Set pic = ActiveSheet.Pictures.Insert(sPath & sName)
With Range("B2")
pic.Top = .Top
pic.Left = .Left
End With
Else
MsgBox sPath & sName & " not found"
End If
End Sub
Any help would be greatly appreciated!
Sincerely,
Doug
I have searched high and low for an answer and I am stumped.
I have a table with two columns. In column A, I have the filename of an
image that I would like to insert into column B. There are over 1,000. Is
there any way to write a macro to insert all of them into Column B based on
the information in Column A? I found this macro for excel but I don't know
if it could be used as a starting point for Word.
Sub ABCD()
Dim pic As Picture
Dim sPath As String, sName As String
Range("B2").Select
sPath = "C:\Graphics\"
sName = Range("A2").Value
If LCase(Right(sName, 4)) <> ".png" Then
sName = sName & ".png"
End If
If Dir(sPath & sName) <> "" Then
Set pic = ActiveSheet.Pictures.Insert(sPath & sName)
With Range("B2")
pic.Top = .Top
pic.Left = .Left
End With
Else
MsgBox sPath & sName & " not found"
End If
End Sub
Any help would be greatly appreciated!
Sincerely,
Doug