|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 lpzxhjp 于 2017-11-26 23:32 编辑
- <div class="blockcode"><blockquote>Sub 添加图片()
- Dim Fullname As String, FileType As String, FileName As String, FileShuoMing As String
- Fullname = Application.GetOpenFilename("图片文件(*.jpg;*.bmp;*.gif;*.png),*.jpg;*.bmp;*.gif;*.png", 1, "选择图片")
- If Fullname = "False" Then Exit Sub
- FileType = Right(Fullname, Len(Fullname) - InStrRev(Fullname, "."))
- If FileType <> "jpg" And FileType <> "bmp" And FileType <> "gif" And FileType <> "png" Then
- MsgBox "选择的图片格式错误或不是图片文件!", , "温馨提示:"
- Exit Sub
- End If
- FileName = Right(Fullname, Len(Fullname) - InStrRev(Fullname, ""))
- With ThisWorkbook.Sheets("WW")
- If IsEmpty(ThisWorkbook.Sheets("WW").Range("a1")) Then
- .Range("a1") = FileName
- Else
- .Range("a65536").End(xlUp).Offset(1, 0) = FileName
- End If
- .Pictures.Insert(Fullname).Name = FileName
- End With
- End Sub
复制代码
Sub 添加图片()
Dim Fullname As String, FileType As String, FileName As String, FileShuoMing As String
Fullname = Application.GetOpenFilename("图片文件(*.jpg;*.bmp;*.gif;*.png),*.jpg;*.bmp;*.gif;*.png", 1, "选择图片")
If Fullname = "False" Then Exit Sub
FileType = Right(Fullname, Len(Fullname) - InStrRev(Fullname, "."))
If FileType <> "jpg" And FileType <> "bmp" And FileType <> "gif" And FileType <> "png" Then
MsgBox "选择的图片格式错误或不是图片文件!", , "温馨提示:"
Exit Sub
End If
FileName = Right(Fullname, Len(Fullname) - InStrRev(Fullname, "\"))
With ThisWorkbook.Sheets("WW")
If IsEmpty(ThisWorkbook.Sheets("WW").Range("a1")) Then
.Range("a1") = FileName
Else
.Range("a65536").End(xlUp).Offset(1, 0) = FileName
End If
.Pictures.Insert(Fullname).Name = FileName
End With
End Sub
用上面的代码在工作表中插入图片时,图片名为“6d81800a19d8bc3e55adf77e878ba61ea9d345d9”一类的图片时,提示“无法设置类pictrue的Name属性,其他简单名称的图片没问题。大神看看为什么?谢谢。
|
|