首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VBA >

Excel技艺,批量导入导出图片VBA

2013-01-27 
Excel技巧,批量导入导出图片VBASub save_pic()For Each p In ActiveSheet.Shapesph p.Heightpw p.Widt

Excel技巧,批量导入导出图片VBA
Sub save_pic()For Each p In ActiveSheet.Shapes ph = p.Height pw = p.Width p.ScaleHeight 1, True p.ScaleWidth 1, True pn = p.TopLeftCell.Offset(0, -1).Value Debug.Print pn, ph, pw, p.Name p.Name = pn p.CopyPicture With ActiveSheet.ChartObjects.Add(0, 0, p.Width + 5, p.Height + 5).Chart .Paste .Export "D:\ex" & p.Name & ".jpg", "JPG" .Parent.Delete End With p.Width = pw p.Height = ph Exit ForNextEnd Sub

?

Sub addpic()For Each Shp In ActiveSheet.Shapes      If Shp.Type = msoPicture Then Shp.Delete  Next  i = 2  Do While Range("A" & i) <> ""  Range("B" & i).Select  Set mypic = ActiveSheet.Pictures.Insert("D:\www\pendant" & Range("A" & i) & ".jpg")  With mypic  .ShapeRange.LockAspectRatio = msoFalse  .Top = Range("B" & i).Top + 5  .Left = Range("B" & i).Left + 5  .Height = Range("B" & i).Height - 10    .Width = Range("B" & i).Width - 10    .Placement = xlMoveAndSize  End With  i = i + 1  Loop  Set mypic = Nothing  End Sub

?

热点排行