Hi,
The bellow code is working in a CATScript, so you can adapt to your code and eventually improve it. If your will run the code from PowerPOint don't forget to get the CATIA object and put the right Reference libraries. There are also few catvba's on Internet which are doing same job (images2MSOffice).
' ======================================================
' Purpose: Macro will take a screen capture in an active CATIA document window
' Usage: 1 - A CATIA document window must be active
' 2 - Run macro
'By ferdo, 6th June 2008
'Comments & small bugfix by JeNdArK
'Adapted for three tipes of photo by Pertu10 ,21/04/2010, for auxcad.com
' ======================================================
Language = "VBSCRIPT"
Sub CATMain()
Dim MyWindow As Window
Dim MyViewer As Viewer
Set MyWindow = CATIA.ActiveWindow
Set MyViewer = MyWindow.ActiveViewer
'**** SET ISOMETRIC VIEW (SITUAR EN VISTA ISOMETRICA)
Dim specsAndGeomWindow1 As Window
Set specsAndGeomWindow1 = CATIA.ActiveWindow
Dim viewer3D1 As Viewer
Set viewer3D1 = specsAndGeomWindow1.ActiveViewer
Dim viewpoint3D1 As Viewpoint3D
Set viewpoint3D1 = viewer3D1.Viewpoint3D
viewer3D1.Reframe
Set viewpoint3D1 = viewer3D1.Viewpoint3D
Dim BGcolor(2) ' Create Array for vector type (x,y,z) // Creamos un array de dimension 1x3
MyViewer.GetBackgroundColor BGcolor ' Keep Background color in the array // Guardamos el color de fondo actual
MyViewer.PutBackgroundColor Array(1, 1, 1) ' Change background color to WHITE // Cambiamos el color del fondo a blanco
' ****** SELECCIONAMOS EL TIPO DE FICHERO *****
Dim extension As String
' ****** PARA ESCOGER LA EXTENSION VALIDA *****
Dim Control As Integer
Control = 0
While Control = 0
If extension = "BMP" Or extension = "JPG" Or extension = "TIFF" Then
Control = 1
Else
extension = UCase(InputBox("Tipo Fichero SIN PUNTO" & Chr(13) & "BMP , JPG o TIFF"))
End If
Wend
'***** ESCOGEMOS LA EXTENSION DEL FICHERO A GRABAR *****
If extension = "BMP" Then
Tipo = catCaptureFormatBMP
End If
If extension = "JPG" Then
Tipo = catCaptureFormatJPEG
End If
If extension = "TIFF" Then
Tipo = catCaptureFormatTIFF
End If
Dim Ruta As String
CapturePath = CATIA.FileSelectionBox("NOMBRE DEL FICHERO", extension, CatFileSelectionModeSave)
Ruta = CapturePath & "." & extension
MyViewer.CaptureToFile Tipo, Ruta ' MAIN SENTENCE!! STORE THE PICTURE IN ANY FORMAT // SENTENCIA PRINCIPAL, GUARDAMOS LA IMAGEN COMO BMP
MyViewer.PutBackgroundColor BGcolor ' Change background color to the original color // Cambiamos el color del fondo al color original
MsgBox (" Capture was saved ") ' Show what we have done / Mostramos lo que hemos hecho
End Sub
Regards
Fernando