Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro with an input dialog box with dropdown 1

Status
Not open for further replies.

TiagoFigueiredo

Industrial
Joined
May 22, 2013
Messages
503
Location
PT
I everyone,

I am trying to make a macro which contains a dialog box, with a dropdown menu, with some predefined values. Any one have tried?

For example:

I would like to run the macro and the dialog box show the sizes of available threads diameters (M4, M5, M6, M8, M10...) Instead of write this values. It's possible to make this?
 
you can do it using VBA and a Form

Eric N.
indocti discant et ament meminisse periti
 
google does

Eric N.
indocti discant et ament meminisse periti
 
Yes you are right, i forgot to say that i'm trying to make that in a macro in Catia. My macro is written in CATScript, and i'm realizing that is not possible with CATScript. Do you suggest to change it to vba?
 
Maybe you can modify this example...

file attached for testing..

Code:
Sub CATMain()
CreateProgressBar
Launch
End Sub

Sub CreateProgressBar()
    Dim ws, fso, Temp, PathOutPutHTML, fhta
    Set ws = CreateObject("wscript.Shell")
    Set fso = CreateObject("Scripting.FileSystemObject")
    Temp = ws.ExpandEnvironmentStrings("%Temp%")
    PathOutPutHTML = Temp & "\ModifyInstances.hta"
    Set fhta = fso.OpenTextFile(PathOutPutHTML, 2, True)
 
fhta.WriteLine "<html>"
fhta.WriteLine "<head>"
fhta.WriteLine "<title>Text</title>"
fhta.WriteLine "<HTA:APPLICATION "
fhta.WriteLine "ID=""objHTA"" "
fhta.WriteLine "APPLICATIONNAME=""Catia_Dropdown"" "
fhta.WriteLine "SCROLL=""NO"" "
fhta.WriteLine "SINGLEINSTANCE=""yes"" "
fhta.WriteLine "Caption = ""no"""
fhta.WriteLine ">"
fhta.WriteLine "</head>"
fhta.WriteLine "<script language=""VBScript"">"
fhta.WriteLine " Sub Window_Onload"
fhta.WriteLine "Dim intWidth, intHeight"
fhta.WriteLine "intWidth = 300"
fhta.WriteLine "intHeight = 100"
fhta.WriteLine "Me.ResizeTo intWidth, intHeight"
fhta.WriteLine "LoadDropDown"
fhta.WriteLine "End Sub"
fhta.WriteLine "Sub LoadDropDown"
fhta.WriteLine "For I=2 TO 10"
fhta.WriteLine "Set objOption = Document.createElement(""OPTION"")"
fhta.WriteLine "objOption.Text = I"
fhta.WriteLine "objOption.Value = I"
fhta.WriteLine "objDrop.Add(objOption)"
fhta.WriteLine "Next"
fhta.WriteLine "End Sub"
fhta.WriteLine "Sub SendToCatia"
fhta.WriteLine "Dim CATIA"
fhta.WriteLine "Set CATIA = GetObject(, ""CATIA.Application"")"
fhta.WriteLine "Dim oPartDocument "
fhta.WriteLine "Dim oPart"
fhta.WriteLine "Dim oCircularPattern "
fhta.WriteLine "Set oPartDocument = CATIA.ActiveDocument"
fhta.WriteLine "Set oPart = oPartDocument.Part"
fhta.WriteLine "Set oCircularPattern = oPart.FindObjectByName(""CircPattern.1"")"
fhta.WriteLine "oCircularPattern.AngularRepartition.InstancesCount.Value = objDrop.value"
fhta.WriteLine "oCircularPattern.CircularPatternParameters = catCompleteCrown"
fhta.WriteLine "oPart.Update"
fhta.WriteLine "window.close"
fhta.WriteLine "End Sub"
fhta.WriteLine "</script>"
fhta.WriteLine "<body>"
fhta.WriteLine "<select name=""objDrop"">"
fhta.WriteLine "</select>"
fhta.WriteLine "<input type=""button"" value=""Send To Catia"" name=""cATIABtn""  onClick=""SendToCatia"">"
fhta.WriteLine "<input id=""BtnExit""   type=""button"" value=""Cancel""   onclick=""window.close"">"
fhta.WriteLine "</body>"
fhta.WriteLine "</html>"
fhta.Close
End Sub



Sub Launch()
Set objShell = CreateObject("Wscript.Shell")
Temp = objShell.ExpandEnvironmentStrings("%Temp%")
PathOutPutHTML = Temp & "\ModifyInstances.hta"
objShell.Run (PathOutPutHTML), 1, True
End Sub

______

Alex ,
 
 http://files.engineering.com/getfile.aspx?folder=415424ea-e2c3-40d9-a122-6c09444bb426&file=CircPattern_HTA.CATPart
Many thanks about this, it looks really what i need. Thanks by your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top