Skip to content

Instantly share code, notes, and snippets.

@umihico
Last active May 18, 2018 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save umihico/a3ec0463399c5087286485f366ec71e6 to your computer and use it in GitHub Desktop.
Save umihico/a3ec0463399c5087286485f366ec71e6 to your computer and use it in GitHub Desktop.
エクセルシート上の画像のファイル名とセル位置の隣に入力し保存するマクロ
Attribute VB_Name = "Module1"
Sub get_image_path_and_current_cell()
Dim pic As Shape, TCht As Object
Dim ACWidth As Long, ACHeight As Long
For Each pic In ActiveSheet.Shapes
Debug.Print (pic.AlternativeText)
Range(pic.TopLeftCell.Address).Offset(0, 1) = pic.AlternativeText
ACWidth = pic.Width
ACHeight = pic.Height
TCht.Paste
TCht.Export Filename:=ThisWorkbook.Path & "\new_pic\" & pic.AlternativeText, filtername:="PNG"
TCht.Parent.Delete
Debug.Print (pic.TopLeftCell.Address)
Next
End Sub