×
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

Macro to run when I open File

Macro to run when I open File

Macro to run when I open File

(OP)
Hello,

I have no clue how to do this. I wanted to create a start part for a group of designers. Any designer opens the file A macro should run automatically and give the results. Is there any way to evoke / trigger macro when a particular file gets opened.

thanks a lot for your help


regards
var

RE: Macro to run when I open File

Instead of having the user open the file, how about having your program open the file and then triggering the method?

RE: Macro to run when I open File

(OP)
Well , This program is a check whether previous user did what supposed to be done on one particular file.
once next user opens file, macro runs and he knows if some thing was not done.

As per your suggestion user should manually run the program. but we want script to run automatically. (not batch scripts)

hope it is clear..

regards
var

RE: Macro to run when I open File

Yes, the user would run the program.
The program opens the file and runs the check.

I can see another way to do this with Reactions; but, again the user would have to launch the check code manually - or the reaction could be set up to fire when something is changed.

If you want to check if something is done, maybe embed the code as a reaction in the starter part.
That way, the check is made at geometry creation time.
sine you are using a start part, I think this is your nest bet.

I have never heard of a OnOpen event attached to a file that can be used as I think you are hoping there is.

Another way to do this is to have a program always running and pinging Catia looking for the file.
When it finds the file is open, it runs the program.
I am no fan of this technique because the program will have to be launched at boot up or as a batch with Catia - to keep it automated.
And it will always be running.
And you need a good ping rate to make sure you get the file as soon as it opens - which might be disruptive to the user that opens the file if they aren't expecting the code to run.
Lots of issues with this idea.....


RE: Macro to run when I open File

(OP)
Yes you are right with program always running has some impact on system performance.

Let me explain our work flow bit more.

Catia user-A required to fill one Excel file after they he done with changes on a part. Some users don not care some users often forget. [glasses].

When subsequent change request comes up, available user (user-B) takes it up and he would know when opening the file that previous user (user-A) did fill the excel or not. If not done, he would intimate user-A and get the necessary Excel form filled up.

This code should run only once. so Iam thinking to do while opening the file.

If i go with reaction, scripts runs again and again obviously we do not want to do. [smile2].

regards
var

RE: Macro to run when I open File

Hello appvid,

The application presented in this video works as follows:
1. Constantly monitors each CATIA Session.
2. On file open, checks the version of it and displays the relevant message.

What you need is a similar, slightly modified, application ie an application which will
1. Constantly monitors each CATIA Session.
2. On file open, checks the name of the file and runs a specific macro.

-GEL
Impossible is nothing.

RE: Macro to run when I open File

(OP)
Exactly, this is what I need.

How do i do this GELFS...

RE: Macro to run when I open File

(OP)
May be FERNANDO will have idea if I can run macro while opening a particular catpart.


RE: Macro to run when I open File

you can create a toolbar that first open your CatPart file then run your macro.

RE: Macro to run when I open File

(OP)
farzad, User still
1) Drag catia file to catia application and open
2) Ctl+o
3) File--open




RE: Macro to run when I open File

+
4) Windows Explorer Double-Click on a CATIA file.
5) Windows Explorer RMB Open
6) CATIA Power Input C:Open
7) CATIA Open in a new Window

-GEL
Impossible is nothing.

RE: Macro to run when I open File

Appvid, I mean if you want to run your macro while opening a practical catpart, you can create a new toolbar and a new command to do this my friend (this's my suggest for you)

but I don't know how you can run your macro while opening a practical catpart with (Ctrl+O)! that is interesting for me too !

RE: Macro to run when I open File

(OP)
Farzad, I believe there is way for running macro while opening part too... Your idea is creative one, but just does not fulfill my needs 100%. Another thing is that I need to run this macro on only production released parts.

1) Macro must only run on few files. ( example- Files in D:/ drive)
2) Macro must only run once on each part in the session

Any one has any idea if i can use mouse clicks on active window to trigger macro by using reactions (KWA).

thanks
var

RE: Macro to run when I open File

Hi,

From my point of view, in a CATIA macro (or an external CATIA application), you can open directly a specific CATIA file and do what ever you want on that part. But what I understood from you is that you need also to check an Excel file if is filed in a specific way or not. What are you checking? Some cells if they are filled or not, a timestamps or? You will need also to check the Excel file in same time, I suppose if all is OK the user can go further...

A CATIA file can be opened without problems, you need to get in your application first CATIA object then do your checks. It's much more complicated if you have more CATIA sessions opened...

For example, the code bellow can be copied and paste in a vbs file (paste in Notepad and change extension from txt to vbs and run by double click). Anyway, for your user can be just one click on an icon to fire a macro in CATIA to do all checks in a specific part and compare with the checks in Excel. Same thing if you will create an external application, depending on what you want.

CODE --> vbs

On Error Resume Next
Set objCATIA = GetObject(, "CATIA.Application")
'~ If Err.Number <> 0 Then  ' this part of code is commented because is supposed that you have already CATIA opened
'~ Set objCATIA = CreateObject("CATIA.Application")
'~ Err.Clear
'~ End If
'~ On Error Goto 0

objCATIA.Visible = true
objCATIA.DisplayFileAlerts = true

'Create a new part in already opened CATIA
'~ Set objProd = objCATIA.Documents.Add("Part")
'Open a  part with name test, change as you wish
Set objProd = objCATIA.Documents.Open("c:\temp\test.CATPart")

Dim oShell

'~ ' Create the WshShell object to run a specific CATScript in CATIA from a specific location
''' the code from that CATScript can be also implemented here but with some modifications...

Set oShell = WScript.CreateObject("WScript.Shell")

oShell.Run ("c:\_Makro\counter_iso.CATScript") 

Regards
Fernando

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

RE: Macro to run when I open File

(OP)
Helloo Fernando, Glad you saw my question and replied. please see the attached picture. I want every one in the team to know if excel file is filled or not after the changes to CATpart (in release directory). All I want to know is there any way to run macro automatically.

I think you will have some idea.

regards
Var

RE: Macro to run when I open File

Now what you want is much more clear for everyone.

In fact, you need a macro to launch a CATPart (this can be done by user in an input box), search the file in R folder, open in CATIA if existing, immediately open excel file (or do it in background), search your CATPart number in the file and check in column A what is filled (is much easier like this, user can compare and see what is missing).

Of course all of these can be done in same macro....I still have something unclear, how or where is specified your CATPart number in excel file? I mean 9999A-004 and all others? I suppose the xls file 9999A is for all of them, isn't it?

See, if you don't give all info's, no one can give a good answer, you will put the developer on a wrong track...

Regards
Fernando

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

RE: Macro to run when I open File

(OP)
Well, I can manage to write script to access excel file and find out which revision is not filled. All I need is how to trigger macro. (Either by rule or reaction automatically).

Your code is to launch Catia and run macro. What I am looking is, Catia session is already open and when I open file macro should.

For example, When you close catia with out saving file, a message pops up saying " DO YOU WANT TO SAVE FILE".... and if you see video from GELFS somehow it reads what version of file and displays it an screen.

see that attached picture too


RE: Macro to run when I open File

Hi,

Did you read the code posted? VBScript is checking first if CATIA is opened (GetObject) and then opening the CATIA file (is not opening CATIA - CreateObject). Of course you need to adapt the code. In same script you can open Excel file and also fire automatically a vba macro already done inside Excel file.

What you want can be done in many ways, depend only what kind of solution you choose. Of course, you can search on Google to see how to open and run automatically a macro in Excel, fired from a vbs script or another kind of application.

Or you can do everything inside a CATIA macro (opening files and checking Excel). I believe you don't need rules or reactions....or if you are more familiar with Excel VBA you can do it directly from there communicating with CATIA...

Regards
Fernando

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

RE: Macro to run when I open File

what appvid wants it's something similar to an "open" event on workbook in excel.. catch the event on CATIA and use to test the letter of the drive..

I do not have any knowledge of caa/rade but i think that is what he is looking for..

RE: Macro to run when I open File

(OP)
hello Fernando, I did see your code. WE do not want to launch catia thru script nor user interface to trigger macro.
AlexLozoya is right, just same as open event on excel. Do I need CAA for this??

RE: Macro to run when I open File

Do you have money for CAA license? 50k (around but with plus smile ) ? And the knowledge to use it (I don't have it)?

I always try to find a reasonable solution, user has to do something... Anyway user has to open the part (no mater what), he can do it with a macro and inside that macro you can put everything....

Hope you understood my point.

Regards
Fernando

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

RE: Macro to run when I open File

(OP)
Looks like my idea is very expensive :-> , I have no knowledge of CAA and my boss has no money to buy CAA.. smile

I got your point... But I have other concerns to go with it. Every minute (from 8AM to 5 PM)designer opens many files from many directories. Designer will not close catia session just open file from a directory where I want to run macro.

Let me work around to stop designers skipping from filling the excel.

thank you all for your valuable suggestions, special thanks to Fernanado you are helpful just as usual.

regards
var

RE: Macro to run when I open File

have you looked in KWA (E) if there are provisions for that action (launch macro on file open)?

RE: Macro to run when I open File

(OP)
As far as I know, NO such option. KWA can not trigger macro automatically. So i gave up.

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