|
由于HTML文件夹生成的image文件存在编号的规律,从001开始,所以可以通过循环单元格对image001进行根据单元格内容改名并移动到桌面
如果有10个批注有图片,其中1张照片重复,那么HTML文件夹里面只会有9张image,001到009,没办法解决
Sub Macro2()
Dim i As Integer
Dim str As String
Dim oldname As String
Dim newname As String
Dim x As String
With ThisWorkbook
For i = 1 To ActiveSheet.UsedRange.Rows.Count
x = i * 10
x = IIf(i < 100, Choose(Len(x), "", "00", "0") & i, i) '生成html文件夹的图片命名是顺序是001,002...需要对序号进行转换
oldname = .Path & "\" & Left(.Name, Len(.Name) - 4) & ".files\image" & x & ".jpg" '测试方便,当前workbook为另存为html的文件,如果直接对xls文件进行操作,需要先另存.
newname = .Path & "\" & Cells(i, 1) & ".jpg" ''默认当前路径是桌面
Debug.Print oldname, newname
Name oldname As newname
Next
End With
End Sub
|
|