Excelマクロ集
をテンプレートにして作成
[
Front page
] [
Page list
|
Search
|
Recent changes
|
RSS of recent changes
]
Start:
***選択範囲のセルの値が画像ファイルへのパスの場合、その画...
複数のセルを選択して同時に処理することもできる。DBに画像...
Sub InsertPicture()
Dim margin As Double
margin = 1
On Error Resume Next
For Each cell In Selection.Cells
cell.Select
ActiveSheet.Pictures.Insert(cell.Value).Select
If Err.Number <> 0 Then
Err.Number = 0
GoTo EndOfForeach
End If
Selection.ShapeRange.LockAspectRatio = msoTrue
'Selection.Placement = xlMoveAndSize
Dim pictWidth As Double
Dim pictHeight As Double
Dim cellWidth As Double
Dim cellHeight As Double
pictWidth = Selection.Width
pictHeight = Selection.Height
cellWidth = cell.Width
cellHeight = cell.Height
If pictWidth / pictHeight > cellWidth / cellHeigh...
Selection.Height = (pictHeight * cellWidth) /...
Selection.Width = cellWidth - margin
Else
Selection.Width = (pictWidth * cellHeight) / ...
Selection.Height = cellHeight - margin
End If
Selection.Top = cell.Top + (cell.Height - Selecti...
Selection.Left = cell.Left + (cell.Width - Select...
cell.Value = ""
EndOfForeach:
Next
End Sub
***コメントをどーぞ [#g4aa676f]
- すばらしすぎるマクロの達人です -- &new{2009-11-21 (土)...
- Excel2010だと、このマクロを使用するとリンクオブジェクト...
#comment
----
[[CategoryMicrosoftOffice]]
End:
***選択範囲のセルの値が画像ファイルへのパスの場合、その画...
複数のセルを選択して同時に処理することもできる。DBに画像...
Sub InsertPicture()
Dim margin As Double
margin = 1
On Error Resume Next
For Each cell In Selection.Cells
cell.Select
ActiveSheet.Pictures.Insert(cell.Value).Select
If Err.Number <> 0 Then
Err.Number = 0
GoTo EndOfForeach
End If
Selection.ShapeRange.LockAspectRatio = msoTrue
'Selection.Placement = xlMoveAndSize
Dim pictWidth As Double
Dim pictHeight As Double
Dim cellWidth As Double
Dim cellHeight As Double
pictWidth = Selection.Width
pictHeight = Selection.Height
cellWidth = cell.Width
cellHeight = cell.Height
If pictWidth / pictHeight > cellWidth / cellHeigh...
Selection.Height = (pictHeight * cellWidth) /...
Selection.Width = cellWidth - margin
Else
Selection.Width = (pictWidth * cellHeight) / ...
Selection.Height = cellHeight - margin
End If
Selection.Top = cell.Top + (cell.Height - Selecti...
Selection.Left = cell.Left + (cell.Width - Select...
cell.Value = ""
EndOfForeach:
Next
End Sub
***コメントをどーぞ [#g4aa676f]
- すばらしすぎるマクロの達人です -- &new{2009-11-21 (土)...
- Excel2010だと、このマクロを使用するとリンクオブジェクト...
#comment
----
[[CategoryMicrosoftOffice]]
Page:
HTML convert time: 0.002 sec.