AccessTr.neT
Buton İle Frame Backcolor Değiştirmek - Baskı Önizleme

+- AccessTr.neT (https://accesstr.net)
+-- Forum: Microsoft Excel (https://accesstr.net/forum-microsoft-excel.html)
+--- Forum: Excel Cevaplanmış Soruları (https://accesstr.net/forum-excel-cevaplanmis-sorulari.html)
+--- Konu Başlığı: Buton İle Frame Backcolor Değiştirmek (/konu-buton-ile-frame-backcolor-degistirmek.html)



Buton İle Frame Backcolor Değiştirmek - accessman - 10/01/2020

Private Sub CommandButton1_Click()
    Dim ctl As Control
    For Each ctl In Me.Form
        If ctl.ControlType = acBoundObjectFrame Then
            If (ctl.Name = Me.TextBox1.Value) Then
                ctl.BackColor = GetHexColor(Me.TextBox2.Value)
            End If
        End If
    Next ctl
    Set ctl = Nothing
End Sub



bu kod ile Excelde
"Me.TextBox1.Value" değerine formdan manuel olarak "Frame8" 
"Me.TextBox2.Value" değerine formdan manuel olarak "#AAECDF"  yazacağım butona bastığımda rengi değişecek kodda 
"Me.Form" ve "acBoundObjectFrame" kalimelerinde hata veriyor nasıl yazmam lazım


Cvp: Buton İle Frame Backcolor Değiştirmek - accessman - 10/01/2020

Me.Form --->  Me.Controls olacakmış
ama frame controlunun karşılığını bulamadım
acFrame olmalı diye düşünüyorum ama olmuyor


Cvp: Buton İle Frame Backcolor Değiştirmek - accessman - 10/01/2020

şeyle bir kod var

Private Sub dene()
    Dim ctrl As Control
    For Each ctrl In Frame1.Controls
        If TypeOf ctrl Is MSForms.OptionButton Then
            If ctrl.Enabled = True Then
                MsgBox ctrl.Name & " is an enabled OptionButton with caption " & ctrl.Caption
            End If
        End If
    Next
End Sub


Cvp: Buton İle Frame Backcolor Değiştirmek - accessman - 10/01/2020

böyle yazdım oldu

Private Sub CommandButton1_Click()
    changeColor Me.TextBox1.Value, Me.TextBox2.Value
End Sub

Private Sub changeColor(controlName As String, colorName As String)
    Dim ctrl As Control
    For Each ctrl In Me.Controls
        If TypeOf ctrl Is MSForms.Frame Then
            If ctrl.Enabled = True Then
                If (ctrl.Name = controlName) Then
                    ctrl.BackColor = GetHexColor(colorName)
                End If
            End If
        End If
    Next
End Sub