Excel 如何用相应的图像替换文本
我有一个excel文档,有300多条记录 在每个记录的第一行中,有一个用户图像变量。 此记录将始终为Excel 如何用相应的图像替换文本,excel,excel-2010,Excel,Excel 2010,我有一个excel文档,有300多条记录 在每个记录的第一行中,有一个用户图像变量。 此记录将始终为username.jpg或空 我有一个文件夹,里面有相应的图片,所有的图片都以完全相同的方式命名 是否有办法自动将第一行中的文本替换为相关图像?如果用户图像变量位于A列,则此代码将图片插入A列,并将行的高度调整为图片的高度。您可能需要稍微调整代码 Sub insertPic() Dim pic As String Dim url As String Dim r As Integer Dim he
username.jpg
或空
我有一个文件夹,里面有相应的图片,所有的图片都以完全相同的方式命名
是否有办法自动将第一行中的文本替换为相关图像?如果用户图像变量位于A列,则此代码将图片插入A列,并将行的高度调整为图片的高度。您可能需要稍微调整代码
Sub insertPic()
Dim pic As String
Dim url As String
Dim r As Integer
Dim he As Integer
url = "C:\User\Pictures\" ' This is the variable to the folder
For r = 1 To 300
pic = Sheets("Sheet1").Range("A" & r).Value ' This is your username file
pic = url & pic
With ActiveSheet.Pictures.Insert(pic) ' Insert picture into active sheet
.Left = ActiveSheet.Range("A" & r).Left ' left and top align the left and top of the picture with the specified cell
.Top = ActiveSheet.Range("A" & r).Top
he = .Height ' get height of image
End With
Sheets("Sheet1").Range("A" & r).Select
Selection.RowHeight = he ' match row height to picture height
Next r
End Sub
应该像(条件)column.row.loadimage()一样简单。尝试在excel上使用visual basic进行一些研究。我不能帮你更多,因为我不会说VB。我想这个链接很接近:xD需要在45分钟内完成这个。。。我是一个爱说话的人。。我还在Excel中寻找一种方法来实现这一点。我已经在从XML生成excel工作表。