- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
        
|
¦^´_ 10# dafa
¶·¬O§A»¡ªº:§â©Ò¦³CommandButton¹ïÀ³Àx¦s®æ¦A¦s¤J¹ïÀ³ªºÀɦW¤~¯à¸Ñ¨M ÀɦW¦s©óSheets("¤u§@ªí1")¸Ì¤~¯à¦p§A©ÒÄ@
½ÐקïGW4501ªí³æUserForm_Initializeµ{¦¡½X ¦p¤U- Option Explicit
- 'Public dw 'GW45011ªí³æ¤£¶·«Å§i: [Module1]¼Ò²Õ¤w«Å§i¹L
- Public Sh As Worksheet '¶··s¥[¤½¥ÎÅÜ¼Æ [TheButton] ¼Ò²Õ¤~¥i¤Þ¥Î
- Dim ButtonClass() As New TheButton
- Private Sub UserForm_Initialize()
- Dim E As Control, i As Integer
- Dim hWnd, tPath, oo
- GW4501.Height = Sheets("¤u§@ªí3").Cells(3, 7) / 5
- GW4501.Width = Sheets("¤u§@ªí3").Cells(3, 2) / 5
- hWnd = GetForegroundWindow
- tPath = ActiveWorkbook.Path & "\©³¹Ï\"
- 'tPath = Application.GetOpenFilename("EXCEÀÉ(*.XLS),*xls")'
- [c1] = tPath
- oo = Dir(tPath)
- If oo = "" Then
- MsgBox "§A©³¹Ï¸ê®Æ§¨¤º¨S©ñ¶i¹ÏÀÉ"
- End
- Else
- [c2] = tPath & oo
- GW4501.Picture = LoadPicture(tPath & oo)
- End If
- 'ButtonClassÅܼƳ]©w¬° New TheButtonª«¥óÃþ§O¼Ò²Õ
- Set Sh = Sheets("¤u§@ªí1") '¤u§@ªíÀx¦s¹Ïªí¸ô®|
- With Sh
- For Each E In Me.Controls
- If InStr(E.Name, "CommandButton") Then
- i = i + 1
- ReDim Preserve ButtonClass(1 To i)
- Set ButtonClass(i).Button = E '«ü©w TheButton.Button(i) ªºª«¥ó
- '*** CommandButton¹ïÀ³Àx¦s®æ¦A¦s¤J¹ïÀ³ªºÀɦW ***
- E.ControlTipText = Cells(i, "A").Address(0, 0) & ":"
- If Dir(.Cells(i, "A").Text) <> "" Then
- E.Picture = LoadPicture(.Cells(i, "A").Text)
- E.ControlTipText = E.ControlTipText & .Cells(i, "A")
- 'CommandButtonªºControlTipText= .Cells(i, "A")ªº¦C¦W¤Î¤º®e(ÀɦW)
- End If
- End If
- Next
- End With
- End Sub
½Æ»s¥N½X ½ÐקïTheButton¼Ò²Õ¤º- Option Explicit
- Public WithEvents Button As MSForms.CommandButton
- Private Sub Button_Click()
- Dim S
- S = Split(Button.ControlTipText, ":")
- If S(1) = "" Then
- Call ´Óª«
- Button.Picture = LoadPicture(dw)
- Button.ControlTipText = Button.ControlTipText & dw
- S = Split(Button.ControlTipText, ":")
- GW4501.Sh.Range(S(0)) = dw
- 'CommandButton¹ïÀ³ªºÀx¦s®æ¦s¤J: ÀɦW
- dw = ""
- End If
- End Sub
½Æ»s¥N½X |
|