|
- Sub main()
- Dim Rng As Range, Desktop As String
- If TypeName(Selection) <> "Range" Then MsgBox "必须选择单元格!", , "提示": Exit Sub
- If Selection.Areas.Count > 1 Then MsgBox "只能选择一个区域!", , "提示": Exit Sub
- Set Rng = Range("A2:B5") '如果需要更改区域只需要更改这里的就可以了。
- Desktop = CreateObject("WScript.Shell").SpecialFolders("Desktop")
- Rng.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
- ActiveSheet.Pictures.Paste.Select
- With Selection
- .Copy
- With ActiveSheet.ChartObjects.Add(0, 0, Selection.Width, Selection.Height).Chart
- .Paste
- .Export Desktop & "" & VBA.Replace(VBA.Replace(Rng.Address, ":", "-"), "$", "") & ".jpg"
- .Parent.Delete
- End With
- .Delete
- End With
- ' Shell "explorer.exe " & Desktop, vbMaximizedFocus '打开文件夹
- End Sub
复制代码 |
|