Learn Excel chart as a picture copy operation

  You can use Excel VBA chart sheet is copied as a picture, to realize this operation using CopyPicture method ChartObjects object. This article describes the Excel chart as a picture copy of the specific methods of operation.

  1. Start Excel and open the worksheet that contains a chart, open the Visual Basic Editor, add a module in the Project Explorer, enter the program code in the "Code" window module. Specific program code as follows:

  Sub CopyChart()

  If ActiveChart Is Nothing Then

  MsgBox "Please select a chart!"

  Exit Sub

  End If

  ActiveChart.CopyPicture appearance:=xlScreen,Format:=xlBitmap

  Range("N8").Select

  ActiveSheet.Paste

  End Sub

  prompt

  In VBA, CopyPicture method can be selected as a picture chart copied to the clipboard, the grammatical structure of the method is as follows:


  Expressions CopyPicture (Appearance, Format)

  Here, the expression is a variable that represents ChartObject object. Appearance of the process parameter is an optional parameter, is used to copy the images provided, the default value is xlScreen. This parameter can be set to one of the following two constants.

  xlPrinter: printing their pictures to copy.

  xlScreen: Pictures as its display screen to copy.

  Format parameter is used to set the image format copy, it defaults to xlPicture. This parameter can be set to one of the following two constants.

  xlBitmap: bitmap (.bmp, .jpg, .gif).

  xlPicture: Draw picture (.png, .wmf, .mix).

  2, press F5 to run the program, select the chart if no worksheet, the program prompt, the user is prompted to select the chart. If you have selected a chart worksheet, select the chart to be copied,


Guess you like

Origin blog.51cto.com/14462329/2427767