Reference: https://wenku.baidu.com/view/6c60420ecc175527072208af.html
For example, to save a selection to a picture on the desktop:
1 Subsave a selection to a picture to the desktop ()2 DimAns as BytePic as String, Paths as String3 on Error Resume Next4Paths =CreateObject("Wscript.Shell"). Specialfolders ("Desktop") &"\" 'record the path to the Desktop folder5 Star:6 'Choose the format of the exported picture7Ans = application.inputbox ("input 1: Save as BMP picture;"+Chr(Ten) +"Input 2: Save as PNG image;"+Chr(Ten) +"Input 3: Save as JPG picture. ","Picture Format",1, , , , ,1)8 IfErr <>0 Then MsgBox "only 1 to 3 can be entered", -,"Tips": Err. Clear:GoToStar'If it is wrong (the value entered is outside 0-255) returns the re-entry9 IfAns <1 OrAns >3 Then MsgBox "Input Error":GoToStar're-enter if not equal to 1, 2, 3TenPic =Choose(ANS,". BMP",". PNG",". JPG")'Choose between three formats One If TypeName(Selection) ="Range" Then 'If the selected object is a cell A DimRng asRange - SetRNG = Selection'assign a selection to a variable rng -Rng. CopyPicture Appearance:=xlscreen,Format: =xlpicture'Copy the rng area as a picture theActiveSheet.UsedRange.Rows (ActiveSheet.UsedRange.Rows.Count +1). Cells (1). Select'Select an empty cell - withACTIVESHEET.CHARTOBJECTS.ADD (0,0, rng. Width, rng. Height). Chart'Generate chart -. Paste'paste a picture into a chart -. Export Paths &Replace(RNG. Address (0,0),":","-") & Pic'export a chart as a picture file +. Parent.delete'Delete a Chart object - End with +Rng. Select'Select Rng Object A End If at Shell "EXPLORER. EXE"& Left(Paths,Len(Paths)-1), vbMaximizedFocus'Open Desktop - End Sub
View Code
VBA in Excel prints numbers and charts in Excel into Word