×
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 make user select an active window

Macro to make user select an active window

Macro to make user select an active window

(OP)

Hello,

I am looking to create a macro that copies and pastes an item from one document to the other. The problem I am having is having the user select their active window. Right now the code specifies which document to paste in. I am looking for code that prompts the user to select their window they want it to be pasted in.

Thanks

Sub CATMain()

Dim documents1 As Documents
Set documents1 = CATIA.Documents

Dim partDocument1 As PartDocument
Set partDocument1 = documents1.Open("Test Model")

Set partDocument1 = CATIA.ActiveDocument

Dim selection1 As Selection
Set selection1 = partDocument1.Selection

selection1.Clear

Dim part1 As Part
Set part1 = partDocument1.Part

Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies

Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.Item("Subdivisions")

Dim hybridShapes1 As HybridShapes
Set hybridShapes1 = hybridBody1.HybridShapes

Dim hybridShapeThickness1 As HybridShapeThickness
Set hybridShapeThickness1 = hybridShapes1.Item("Test Surface")

selection1.Add hybridShapeThickness1

selection1.Copy

Dim windows1 As Windows
Set windows1 = CATIA.Windows

Dim specsAndGeomWindow1 As SpecsAndGeomWindow
Set specsAndGeomWindow1 = windows1.Item("PART1")

specsAndGeomWindow1.Activate

Dim partDocument2 As PartDocument
Set partDocument2 = CATIA.ActiveDocument

Dim selection2 As Selection
Set selection2 = partDocument2.Selection

selection2.Clear

Dim part2 As Part
Set part2 = partDocument2.Part

selection2.Add part2

selection2.Paste

RE: Macro to make user select an active window

Hi,

Probably you will need to use catvba with a form showing a dropdown list. In that list you can pick your window name...otherwise if you cannot use catvba you have to get all CATIA windows, show the name to user and let him choose the right window (and in catvba should be same procedure but much nicer smile ).

Regards
Fernando

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

RE: Macro to make user select an active window

(OP)
Yeah I am using a form for them to choose which part they want copied and pasted. Just having a tough time figuring out how to make a window active by selection.

I am probably going to have the macro create a new document and have it paste into there so the macro can work consistently. This way I wont have to worry about the user selecting an active window it will just create a new one for them.

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