×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

is it possible to make an exe out of an VBA project? or to run a script outside de VB editor?

is it possible to make an exe out of an VBA project? or to run a script outside de VB editor?

is it possible to make an exe out of an VBA project? or to run a script outside de VB editor?

(OP)
Hi guys, i was wondering if a could make an exe out of an VBA project, since i couldn't run it from VBS by pasting the code directly into it,

- is there a way to run it outside the visual basic editor?
- should i buy VB6 and try to run it from there?

THANKs in advance.

here's my code

CODE --> VBA

Sub CATmain()

'Declaracion de variables
Dim spabench As SPAWorkbench
Dim mymeas
Dim ref1 As Reference
Dim myans As Double
Dim InputObjectType(0)

'Devuelve el numero de caras de la parte
Set objsel = CATIA.ActiveDocument.Selection
objsel.Clear
objsel.Search "Type=Topology.Face,all"
MsgBox objsel.Count2
X = objsel.Count2

'**************CICLO***************
For i = 1 To 5 'Aqui va x


Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set Selection = partDocument1.Selection

Set ref1 = Selection.Item(i).Reference
Set spabench = partDocument1.GetWorkbench("SPAWorkbench")
Set mymeas = spabench.GetMeasurable(ref1)
Dim mycoord(2)
mymeas.GetCOG mycoord
MsgBox mycoord(0)
Next

'***********************************
End Sub 

RE: is it possible to make an exe out of an VBA project? or to run a script outside de VB editor?

(OP)
thanks ferdo, i will be looking a way to do it a post it.

RE: is it possible to make an exe out of an VBA project? or to run a script outside de VB editor?

A small modification in your code and it runs from CATScript. Still, you can show us how did you tried to run the macro not from vba editor.

CODE --> CATScript

Sub CATmain()

'Declaracion de variables
Dim spabench As SPAWorkbench
Dim mymeas
Dim ref1 As Reference
Dim myans As Double
Dim InputObjectType(0)

'Devuelve el numero de caras de la parte
Set objsel = CATIA.ActiveDocument.Selection
objsel.Clear
objsel.Search "Type=Topology.Face,all"
MsgBox objsel.Count2
X = objsel.Count2

'**************CICLO***************
For i = 1 To 5 'Aqui va x


Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set Selection = partDocument1.Selection

Set ref1 = Selection.Item(i).Reference
Set spabench = partDocument1.GetWorkbench("SPAWorkbench")
Set mymeas = spabench.GetMeasurable(ref1)
ReDim mycoord(2)
mymeas.GetCOG mycoord
MsgBox mycoord(0) & "    " & mycoord(1) & "    " & mycoord(2)
Next

'***********************************
End Sub 

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: is it possible to make an exe out of an VBA project? or to run a script outside de VB editor?

(OP)
it works now, apparently it is not neccesary to declare the variable type, as follows.

CODE --> CATscript

Sub CATmain()

'Declaracion de variables
Dim spabench 
Dim mymeas
Dim ref1 
Dim myans 
Dim InputObjectType(0)

'Devuelve el numero de caras de la parte
Set objsel = CATIA.ActiveDocument.Selection
objsel.Clear
objsel.Search "Type=Topology.Face,all"
MsgBox objsel.Count2
X = objsel.Count2

'**************CICLO***************
For i = 1 To 5 'Aqui va x


Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set Selection = partDocument1.Selection

Set ref1 = Selection.Item(i).Reference
Set spabench = partDocument1.GetWorkbench("SPAWorkbench")
Set mymeas = spabench.GetMeasurable(ref1)
ReDim mycoord(2)
mymeas.GetCOG mycoord
MsgBox mycoord(0) & "    " & mycoord(1) & "    " & mycoord(2)
Next

'***********************************
End Sub 

and it works from a macro .catvbs file outside VBA.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources