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
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
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Macro to make user select an active window
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.