property Gauge.CopyTo (File as String) as Variant
Exports the control's view to an EMF file.

TypeDescription
File as String A string expression that specifies the full name and path of the file to be saved, including its extension. If the File parameter is provided, the CopyTo property attempts to save the content to the specified file. In this case, it returns True if the operation succeeds, or False if it fails (for example, if the path is invalid or write access is denied). If the File parameter is missing or empty, the CopyTo property does not save to disk but instead returns a one-dimensional safe array of bytes containing the EMF content.

If the File parameter is not empty, the extension ( characters after last dot ) determines the graphical/ format of the file to be saved as follows:

  • *.bmp, *.dib, *.rle, saves the control's content in BMP format (Example: "snapshot.bmp", "c:\temp\snapshot.bmp")
  • *.jpg, *.jpe, *.jpeg, *.jfif, saves the control's content in JPEG format (Example: "snapshot.jpg", "c:\temp\snapshot.jpeg")
  • *.gif, saves the control's content in GIF format (Example: "snapshot.gif", "c:\temp\snapshot.gif")
  • *.tif, *.tiff, saves the control's content in TIFF format (Example: "snapshot.tif", "c:\temp\snapshot.tiff")
  • *.png, saves the control's content in PNG format (Example: "snapshot.png", "c:\temp\snapshot.png")
  • *.pdf, saves the control's content to PDF format. The File argument may carry up to 4 parameters separated by the | character in the following order:

    filename.pdf | paper size | margins | options

    In other words, you can specify the following fields:

    • filename (first field), to define the name (including the path) of the PDF file to be saved. The name must include the .pdf extension (Example: "c:/temp/fit.pdf" -> saves the fit.pdf file in the c:/temp folder)
    • paper size (second field), to define the size of the paper to be used. Default is A4 (210 mm x 297 mm). Values can be in any of these units: pt, mm, cm, in or px. The default unit is pt. (Example: "8.27 in x 11.69 in" -> indicates the A4 paper-format in inches)
    • margins (third field), to define the paper margins in the order: left top right bottom. Values can be in any of these units: pt, mm, cm, in or px. The default unit is pt. If the field is left empty, the default margins are applied: 12.7 mm for all sides (Example: "10mm 15mm 10mm 15mm", defines the margins as left = 10 mm, top = 15 mm, right = 10 mm, bottom = 15 mm)
    • options (fourth field), to define the PDF scaling options as one of the following:
      • Page-fit scaling of [w] x [h] format described as:
        • Only w specified: Fit content to w pages wide, and as many pages tall as required (Example: "1 x")
        • Only h specified: Fit content to h pages tall, and as many pages wide as required (Example: "x 2")
        • Both w and h fields specified:
          • if the option ends with 'f', stretches the content to exactly w pages wide by h pages tall. (Example: "2 x 3f")
          • Otherwise, fits the content within up to w pages wide by h pages tall (Example: "2 x 3")
        • Neither w nor h specified, places the content on as many pages as required (Example: "x")
      • Percentage scaling (p%), scales content uniformly by the specified percentage p. (Example: "50%", reduces content to half its original size)
      • Single-page (single), places all content on a single page, regardless of its original size (Example: "single")

    to build the PDF document. 

    The units  for the paper size and margins can be:

    • pt for PostScript Points,
    • mm for Millimeters,
    • cm for Centimeters
    • in for Inches
    • px for pixels

    If the unit is omitted, PostScript points (pt) are used by default. For example, 8.27 in x 11.69 in specifies the paper size in inches.

    For instance:

    • "c:\temp\snapshot.pdf|||single", exports the content to a single A4 page (default margins)
    • "fit.pdf|||1 x", fit content to 1 page wide, as many A4 pages tall as required (default margins)
    • "fit.pdf|8.50 in x 11.00 in||x 2", fit content to 2 Leter pages tall, automatically determine pages wide (default margins)
    • "fit.pdf|16.54 in x 11.69 in|5 mm 5 mm 5 mm 5 mm|3 x 2", fit content 3 A3-landscape pages wide by 2 pages tall (custom margins)
    • "fit.pdf|||3 x 2f", fit content exactly 3 A4 pages wide by 2 pages tall (default margins)
    • "fit.pdf|6.93 in x 9.84 in||75%", scale content proportionally by 75% using B3 pages (default margins)
    • "shot.pdf|33.11 in x 46.81 in|0 0 0 0|single", exports the content to an A0 single PDF page, with no margins

    By default, the paper size is 210 mm × 297 mm ( A4 format ) and the margins are 12.7 mm 12.7 mm 12.7 mm 12.7 mm

  • *.emf or any other extension determines the control to save the control's content in EMF format.
Variant A boolean value indicating whether the file was successfully saved when the File parameter is specified and not empty, or a one-dimensional safe array of bytes containing the EMF content when the File parameter is an empty string
The CopyTo method copies/exports the control's view to BMP, PNG, JPG, GIF, TIFF, PDF or EMF graphical files.

The following VB sample saves the control's content to a EMF file:

If (Control.CopyTo("c:\temp\test.emf")) Then
    MsgBox "test.emf file created, open it using the mspaint editor."
End If

The following VB sample prints the EMF content ( as bytes, File parameter is empty string ):

Dim i As Variant
For Each i In Control.CopyTo("")
    Debug.Print i
Next