VBA Form

VBA Form

sam
Advocate Advocate
565 Views
3 Replies
Message 1 of 4

VBA Form

sam
Advocate
Advocate

Hi, 

I have created a form backed by long code and on form there are few different controls e.g., textbox, cmoboboxes and option buttons. These inputs are entered in random order depending on different situation/users. I want to hold execution of code untill ok is pressed. Can someone guide me please to right example or give me a suggestion to how to tackle this. 

Regards, 

Sam

0 Likes
Accepted solutions (1)
566 Views
3 Replies
Replies (3)
Message 2 of 4

marcin_otręba
Advisor
Advisor
Accepted solution

just put your code in button.click event. I assume right now you have it under TextBox.TextChanged or something ?

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

Message 3 of 4

tonythm
Advocate
Advocate

Some code for you refer:

Need create button for show form.

Public Sub Showuserform()
  
    iProperties.Show
End Sub
Private Sub CommandButton1_Click()
    Dim oWkbk As Workbook
    Set oWkbk = ThisWorkbook

    Dim oSheet As Worksheet
    Set oSheet = oWkbk.ActiveSheet

    Dim oInv As Inventor.Application
    Set oInv = GetObject(, "Inventor.Application")

    Dim oDoc As Document
    Set oDoc = oInv.ActiveDocument
    
    Dim oProjectPropertySet As Inventor.PropertySet
    Set oProjectPropertySet = oDoc.PropertySets.Item("Design Tracking Properties")
    Dim oSummaryPropertySet As Inventor.PropertySet
    Set oSummaryPropertySet = oDoc.PropertySets.Item("Inventor Summary Information")
    Dim oDocSummaryPropertySet As Inventor.PropertySet
    Set oDocSummaryPropertySet = oDoc.PropertySets.Item("Inventor Document Summary Information")
    Dim oCustomPropertySet As Inventor.PropertySet
    Set oCustomPropertySet = oDoc.PropertySets.Item("Inventor User Defined Properties")
        
    Dim oPartNumber As Property
    Set oPartNumber = oDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number")

    Dim oDisplayName As String
    oDisplayName = oDoc.DisplayName
    oDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value = oDisplayName
    
    If oInv.ActiveDocument.DocumentType = kPartDocumentObject Then
        Dim oPart As PartDocument
        Set oPart = oInv.ActiveDocument
            
        'Summary iProperties
        oSummaryPropertySet.Item("Title").Value = iProperties.Frame1.TextBox1.Value
        oSummaryPropertySet.Item("Subject").Value = iProperties.Frame1.TextBox2.Value
        oSummaryPropertySet.Item("Author").Value = iProperties.Frame1.TextBox3.Value
        oDocSummaryPropertySet.Item("Manager").Value = iProperties.Frame1.TextBox4.Value
        oDocSummaryPropertySet.Item("Company").Value = iProperties.Frame1.TextBox5.Value
        oDocSummaryPropertySet.Item("Category").Value = iProperties.Frame1.TextBox6.Value
        oSummaryPropertySet.Item("Keywords").Value = iProperties.Frame1.TextBox7.Value
        oSummaryPropertySet.Item("Comments").Value = iProperties.Frame1.TextBox8.Value
        
        'Project iProperties
        oProjectPropertySet.Item("Stock Number").Value = iProperties.Frame2.TextBox10.Value
        oProjectPropertySet.Item("Description").Value = iProperties.Frame2.TextBox11.Value
        oSummaryPropertySet.Item("Revision Number").Value = iProperties.Frame2.TextBox12.Value
        oProjectPropertySet.Item("Project").Value = iProperties.Frame2.TextBox13.Value
        oProjectPropertySet.Item("Designer").Value = iProperties.Frame2.TextBox14.Value
        oProjectPropertySet.Item("Engineer").Value = iProperties.Frame2.TextBox15.Value
        oProjectPropertySet.Item("Authority").Value = iProperties.Frame2.TextBox16.Value
        oProjectPropertySet.Item("Cost Center").Value = iProperties.Frame2.TextBox17.Value
        
        'Custom iProperties
        oCustomPropertySet.Item("0MF").Value = iProperties.Frame3.TextBox18.Value
        oCustomPropertySet.Item("0ŽQl}–ʔԍ†").Value = iProperties.Frame3.TextBox19.Value
        oCustomPropertySet.Item("0•iŽ¿ŠÇ—").Value = iProperties.Frame3.TextBox20.Value
        oCustomPropertySet.Item("0‹qæ–¼").Value = iProperties.Frame3.TextBox21.Value
        oCustomPropertySet.Item("0’S“–").Value = iProperties.Frame3.TextBox22.Value
        oCustomPropertySet.Item("0Ží•Ê").Value = iProperties.Frame3.TextBox23.Value
        oCustomPropertySet.Item("MODEL_CODE").Value = iProperties.Frame3.TextBox24.Value
        oCustomPropertySet.Item("PL_NEXT").Value = iProperties.Frame3.TextBox25.Value
        oCustomPropertySet.Item("PL_NOTE").Value = iProperties.Frame3.TextBox26.Value
        oCustomPropertySet.Item("PL_•iŽ¿G").Value = iProperties.Frame3.TextBox27.Value
        oCustomPropertySet.Item("PL_¡–@Ž¿—Ê‹LŽ–_A").Value = iProperties.Frame3.TextBox28.Value
        oCustomPropertySet.Item("PL_¡–@Ž¿—Ê‹LŽ–_B").Value = iProperties.Frame3.TextBox29.Value
        oCustomPropertySet.Item("PL_¡–@Ž¿—Ê‹LŽ–_C").Value = iProperties.Frame3.TextBox30.Value
        oCustomPropertySet.Item("PL_¡–@Ž¿—Ê‹LŽ–_D").Value = iProperties.Frame3.TextBox31.Value
        oCustomPropertySet.Item("PL_¡–@Ž¿—Ê‹LŽ–_Œ`F").Value = iProperties.Frame3.TextBox32.Value
        oCustomPropertySet.Item("PL_Þ—¿ƒR[ƒh_C").Value = iProperties.Frame3.TextBox33.Value
        oCustomPropertySet.Item("PL_Þ—¿ƒR[ƒh_PG").Value = iProperties.Frame3.TextBox34.Value
        oCustomPropertySet.Item("PL_Þ—¿ƒR[ƒh_•ª—Þ").Value = iProperties.Frame3.TextBox35.Value
        oCustomPropertySet.Item("PL_Þ—¿ƒR[ƒh_Žq}”Ô").Value = iProperties.Frame3.TextBox36.Value
        oCustomPropertySet.Item("PL_•\–ʏˆ—ƒ\ƒm‘¼_1").Value = iProperties.Frame3.TextBox37.Value
        oCustomPropertySet.Item("PL_•\–ʏˆ—ƒ\ƒm‘¼_2").Value = iProperties.Frame3.TextBox38.Value
        oCustomPropertySet.Item("PL_»•iŒÂ”").Value = iProperties.Frame3.TextBox39.Value
        oCustomPropertySet.Item("PL_’²’B•i—v‹Ž–€Žw’è_ADD").Value = iProperties.Frame3.TextBox40.Value
        oCustomPropertySet.Item("PL_’²’B•i—v‹Ž–€Žw’è_b").Value = iProperties.Frame3.TextBox41.Value
        oCustomPropertySet.Item("PL_’²’B•i—v‹Ž–€Žw’è_c").Value = iProperties.Frame3.TextBox42.Value
        oCustomPropertySet.Item("PL_’²’B•i—v‹Ž–€Žw’è_d").Value = iProperties.Frame3.TextBox43.Value
        oCustomPropertySet.Item("PL_’²’B•i—v‹Ž–€Žw’è_e").Value = iProperties.Frame3.TextBox44.Value
        oCustomPropertySet.Item("PL_’²’B•i—v‹Ž–€Žw’è_f").Value = iProperties.Frame3.TextBox45.Value
        oCustomPropertySet.Item("PL_’²’B•i—v‹Ž–€Žw’è_g").Value = iProperties.Frame3.TextBox46.Value
        oCustomPropertySet.Item("PL_’²’B•i—v‹Ž–€Žw’è_h").Value = iProperties.Frame3.TextBox47.Value
        oCustomPropertySet.Item("PL_’²’B•i—v‹Ž–€Žw’è_j").Value = iProperties.Frame3.TextBox48.Value
        oCustomPropertySet.Item("PL_’²’B•i—v‹Ž–€Žw’è_k").Value = iProperties.Frame3.TextBox49.Value
        oCustomPropertySet.Item("PL_’²’B•i—v‹Ž–€Žw’è_l").Value = iProperties.Frame3.TextBox50.Value
        oCustomPropertySet.Item("PL_’²’B•i—v‹Ž–€Žw’è_m").Value = iProperties.Frame3.TextBox51.Value
        Dim ƒeƒ“ƒvƒŒ[ƒg‰ü’ù“ú As Date
        oCustomPropertySet.Item("ƒeƒ“ƒvƒŒ[ƒg‰ü’ù“ú").Value = iProperties.Frame3.TextBox52.Value
        oCustomPropertySet.Item("ŒŸõƒR[ƒh").Value = iProperties.Frame3.TextBox53.Value
        oCustomPropertySet.Item("•\‘è—“_TITLE").Value = iProperties.Frame3.TextBox54.Value
        
    ElseIf oInv.ActiveDocument.DocumentType = kAssemblyDocumentObject Then
        Dim oAssy As AssemblyDocument
        Set oAssy = oInv.ActiveDocument
    End If


MsgBox ("iProperties updated")
Set oExcel = Nothing
' Update part/assembly
oDoc.Update
ActiveWorkbook.Save

End Sub

Private Sub CommandButton2_Click()
    iProperties.Hide
End Sub

 

Message 4 of 4

sam
Advocate
Advocate

@marcin_otręba 

 

Thank you so much. 

0 Likes