Sub sitepicget() '提取照片 Dim str Dim wb, wb1 As Workbook Dim i AsInteger Dim j, k AsLong Dim shp As Shape Dim shtname AsString shtname = InputBox("请输入待提取照片所在的表的名称。比如:关键点拍照 注意:每次只能输入一个") OnErrorResumeNext str = Application.GetOpenFilename(",*.*", , , , True) For i = LBound(str) To UBound(str) Set wb = Workbooks.Open(str(i)) For j = 1To Sheets(shtname).Shapes.Count Set shp = Sheets(shtname).Shapes(j) shp.CopyPicture Appearance:=xlScreen, Format:=xlPicture With Sheets(shtname).ChartObjects.Add(shp.Left, shp.Top, shp.Width, shp.Height) .Activate EndWith ActiveChart.Paste ActiveChart.Export ("D:\picture\" & Left(wb.name, InStr(wb.name, ".") - 1) & "-" & shtname & "-" & j & ".png") ActiveChart.Parent.Delete Next
Application.DisplayAlerts = False 'wb.Save wb.Close Next EndSub