Skip to content
✦ Made with Docsie · generated from video

How to Write Macros in CATIA

This guide shows you how to write macros in CATIA using VBA (Visual Basic for Applications). You will learn how to set up a dedicated macro folder, create a new VBA macro library, write a simple test macro by hand, and record a macro automatically based on actions performed in the CATIA workspace. By the end, you will know how to manage multiple macros from the Macros dialog.

CATIA 10 steps 5 screenshots 924 words Source video 2:59 Generated cost $1.05

Video: CATIA V5 - VBA MACROS - RECORDING MACROS - CREATE A POINT by HOW2CATIA (2020). All credit for the demonstration goes to the creator; watch the original on YouTube. The written guide below was generated from this video by Docsie. Creator? Request a change or removal.

This guide shows you how to write macros in CATIA using VBA (Visual Basic for Applications). You will learn how to set up a dedicated macro folder, create a new VBA macro library, write a simple test macro by hand, and record a macro automatically based on actions performed in the CATIA workspace. By the end, you will know how to manage multiple macros from the Macros dialog.

Prerequisites

  • CATIA V5 installed on your system.
  • Access to Windows Explorer to create a folder structure for storing macros.
  • Basic familiarity with the CATIA V5 interface and the Tools menu.
1

Create a folder to store your macros

Before writing macros in CATIA, set up a dedicated folder to keep your VBA projects organized.

  • Open Windows Explorer and navigate to the root directory (for example, *C:*).
  • Right-click in the white space of the directory window to open the context menu.
  • Select New > Folder.
  • Name the new folder MACROS.
Windows Explorer window showing the creation of a new folder named MACROS, with a context menu open and a cursor highlight
Windows Explorer window showing the creation of a new folder named MACROS, with a context menu open and a cursor highlight
2

Verify the folder is empty

Confirm that the new folder is ready to receive your macro project.

  • Double-click the MACROS folder to open it.
  • Confirm that the folder is empty. The message "This folder is empty" should be displayed.
3

Open CATIA V5 and access macro libraries

With your folder ready, open CATIA V5 to begin creating your first macro library.

  • Launch CATIA V5 and open a new or existing part document.
  • Go to the top menu and click Tools.
  • In the dropdown menu, hover over Macro and select the option to manage macro libraries.
CATIA V5 interface with the Tools menu open, Macro submenu visible, and cursor highlighting the selection
CATIA V5 interface with the Tools menu open, Macro submenu visible, and cursor highlighting the selection
4

Create a new VBA macro library

Now create the VBA project that will hold your macros.

  • In the Macro libraries dialog, ensure Library type is set to VBA projects.
  • Click Create new library... on the right.
  • In the dialog that appears, paste the full path to the MACROS folder you created (for example, C:\MACROS\VBAProject1.catvba).
  • Click OK to create the new VBA project in the specified folder.
Macro libraries dialog in CATIA V5, with a prompt to paste the folder path for the new VBA project
Macro libraries dialog in CATIA V5, with a prompt to paste the folder path for the new VBA project
5

Create a simple test macro

Write your first macro by hand to confirm the VBA editor is working correctly.

  • The Microsoft Visual Basic for Applications (VBA) editor opens automatically with the new project.
  • Under VBAProject1 (C:\MACROS\VBAProject1.catvba), expand Modules and select Module1.
  • In the code window, type the following code:
Sub CATMain()
    MsgBox "Hello"
End Sub
  • This macro displays a message box with the text "Hello" when run.
6

Start recording a new macro

Beyond writing code manually, you can also record a macro in CATIA based on your actions in the workspace.

  • In CATIA V5, open the Record macro dialog.
  • Confirm the following settings:
  • Current macro library or document: C:\MACROS\VBAProject1.catvba
  • Language used: MS VBA
  • Macro name: Module2
  • Click Start to begin recording a new macro.
CATIA V5 "Record macro" dialog with macro library path, language set to MS VBA, macro name as Module2, and cursor over the Start button
CATIA V5 "Record macro" dialog with macro library path, language set to MS VBA, macro name as Module2, and cursor over the Start button
7

Perform the actions to record

With recording active, perform the actions you want captured in the macro.

  • In the CATIA workspace, perform the desired actions to be recorded.
  • In this example, a new point is created in the tree under Geometrical Set.1 as Point.1.
  • The cursor indicates the selection or creation action.
  • The tree structure on the left now shows:
  • Part1
  • xy plane, yz plane, zx plane
  • PartBody
  • Geometrical Set.1
    • Point.1 (highlighted, indicating selection)
8

Review the automatically generated macro code

After recording, inspect the code CATIA generated for your actions.

  • The VBA editor opens and displays the new module (Module2) under the same project.
  • The code window contains the automatically generated VBA code for the recorded actions:
Sub CATMain()
    Dim partDocument1 As PartDocument
    Set partDocument1 = CATIA.ActiveDocument

    Dim part1 As Part
    Set part1 = partDocument1.Part

    Dim hybridBodies1 As HybridBodies
    Set hybridBodies1 = part1.HybridBodies

    Dim hybridBody1 As HybridBody
    Set hybridBody1 = hybridBodies1.Add()

    Dim hybridShapeFactory1 As HybridShapeFactory
    Set hybridShapeFactory1 = part1.HybridShapeFactory

    Dim hybridShapePointCoord1 As HybridShapePointCoord
    Set hybridShapePointCoord1 = hybridShapeFactory1.AddNewPointCoord(0#, 0#, 0#)

    hybridBody1.AppendHybridShape hybridShapePointCoord1
    part1.InWorkObject = hybridShapePointCoord1
    part1.Update
End Sub
  • This code creates a new point at coordinates (0, 0, 0) in the part document.
VBA editor showing Module2 with auto-generated code for creating a point at (0,0,0) in CATIA V5
VBA editor showing Module2 with auto-generated code for creating a point at (0,0,0) in CATIA V5
9

Insert a new module in the VBA project

You can add additional modules to the same project to organize further macros.

  • In the VBA editor, right-click the project tree under VBAProject1.
  • Hover over Insert and select Module from the context menu.
  • This action adds a new module (Module3) to the project.
10

Review all available macros

Finally, open the Macros dialog to see and manage everything you have created.

  • In CATIA V5, open the Macros dialog.
  • The dialog lists all available macros in the current macro library:
  • Module1 (MS VBA)
  • Module2 (MS VBA)
  • Module3 (MS VBA)
  • From this dialog, you can select, run, edit, create, rename, or delete macros.

Summary

You have now learned how to write macros in CATIA V5 using two approaches: manually typing VBA code into a module, and recording a macro by performing actions directly in the CATIA workspace. You also know how to organize macros into multiple modules within a single VBA project and manage them all from the Macros dialog.

What's next

  • Experiment with editing the recorded code in Module2 to customize the point creation logic.
  • Try recording additional actions to generate more advanced macros automatically.
  • Use the Macros dialog to rename, organize, or delete macros as your project grows.
Generation details: cost, quality tiers

Docsie billed 1,500 credits ($1.05) to analyze this 3-minute video at standard quality. The rewrite, template fill and Word/PDF exports were included. The same video at each quality tier:

QualityFrames sampledCreditsApprox. cost
Draftevery 16-30 s750$0.52
Standard (this guide)every 8-15 s1,500$1.05
Detailedevery 4-7 s3,000$2.10
Ultraevery 1-3 s6,000$4.20

Credits priced at $0.70 per 1,000; plans include a monthly allowance. Enterprise customers on on-premise or bring-your-own-model deployments run this on their own inference and pay no per-video credits.

Generated by Docsie Video-to-Docs on 2026-10-11 from a 2-minute video. Screenshots are frames from the source video and belong to their creator, HOW2CATIA, whose original is embedded above. If you own this video and want the guide removed or credited differently, contact us and we will act within one business day.

Turn your own training videos into guidesJoin teams that save hours, reduce documentation work and scale training with Docsie.
See Docsie in action. No commitment.

Ready to Transform Your Documentation?

Start creating professional documentation that your users will love