0

I am working with Catia V5 at the moment, and need to translate a code snippet written in what I believe is VB Script to VBA.

Specifically, I have the following snippet which I am stuck on at the moment:

oSelection1.VisProperties.SetShow(INFITF.CatVisPropertyShow.catVisPropertyNoShowAttr)

Currently when I run this code there is an Runtime Error (#424), stating that I need to define an object. oSelection1 is defined as a Selection.

Could anyone point me in the right direction here? I am very new to VBA so I apologize if this is a rookie question.

najusten
  • 59
  • 6
  • 1
    Why do you think in was VBScript, and what is `INFITF`? – GSerg Jan 27 '20 at 15:48
  • 1
    `Selection` is not a valid Object type. You *could* `Dim oSelection1 As Object` to keep it generic, but you would be better working out what the *actual* Object type is – Chronocidal Jan 27 '20 at 15:49
  • Don't think that anyone will help, unless you show more code. – Vitaliy Prushak Jan 27 '20 at 15:52
  • I believe it is VB Script based on the amount of googling and scanning of other code snippets I've done. I previously defined the selection as follows: `Set oSelection1 = o_Catia.ActiveDocument.Selection`. If I define it as `Dim oSelection1 As Object`, then the next line: `oSelection1.Clear` throws an error (#91). – najusten Jan 27 '20 at 15:53
  • 1
    @najusten I assume you've replaced `Set oSelection1 = ...` with `Dim oSelection1 As Object`. You should have added `Dim oSelection1 As Object` in front of the `Set oSelection1 = ...`. That still does not answer why you think it was VBScript (and not VBA to begin with) and, more importantly, what is `INFITF`. – GSerg Jan 27 '20 at 16:45
  • VBScript is legal VBA. –  Jan 27 '20 at 18:27
  • 1
    @Mark [VBScript Features not in Visual Basic for Applications](https://www.vbsedit.com/html/f65b4a7c-eb8c-47f1-ba36-16ad8793026d.asp) – GSerg Jan 27 '20 at 18:57
  • I have the help file. The code snippert is legal VBA or VBScript. And is also legal VB.NET. Help file is downloadable here http://download.microsoft.com/download/winscript56/Install/5.6/W982KMeXP/EN-US/scrdoc56en.exe –  Jan 27 '20 at 19:02
  • @Mark You didn't say anything about this code snippet. You said that any VBScript is legal VBA, that is not true. – GSerg Jan 27 '20 at 19:04
  • What else would I be talking about. –  Jan 27 '20 at 19:05
  • 1
    [Minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) please. Otherwise it's not possible to help you. – gdir Jan 27 '20 at 22:44
  • Please check CATIA help file in your CATIA installation folder, is called v5automation.chm , see image below what you need to search in that file. [![enter image description here](https://i.stack.imgur.com/YauAn.png)](https://i.stack.imgur.com/YauAn.png) – ferdo Jan 28 '20 at 04:34
  • Thank you for all the feedback! I do not have access to the downloadable help documentation you posted right now, but I will look at that as soon as I get the chance. I tried creating a new Module in Catia, and recording a Macro during which I hide the selected entity - `oSelection1.VisProperties.SetShow 1` achieves this. I hope these snippets accomplish the same task..? – najusten Jan 28 '20 at 09:45
  • That looks like it came from of a VB.NET application not VBSCript. 1. In VB.NET the value of the enumeration would be fully qualified (as it is here) and 2. Parentheses are used for a subroutine call, but without the CALL keyword. – C R Johnson Jan 28 '20 at 17:10

0 Answers0