ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ¦p¦ó±NA5¯È±i®æ¦¡¤@¦¸¦C¦L©óA4¯È±iª½±µ²£¥Í¤G¥÷ªí®æ

¦^´_ 3# dechiuan999
¨Ì1#ªþÀÉ ²Ä¤@­Óªí®æ©Ò¼g, ¸Õ¸Õ¬Ý
  1. Option Explicit
  2. Dim Sh As Worksheet, Rng As Range
  3. Sub «ö¶s()       '«ö¯Ã«ü©wªºµ{¦¡
  4.     Dim ¦L¦C As String
  5.     Set Sh = ActiveSheet
  6.     Set Rng = Sh.[A1:G20]                            'ªí®æ½d³ò
  7.     Do
  8.         ¦L¦C = InputBox("¦L¦Cªí®æ:  ½Ð¿é¤J  1 ©Î 2 ", "¦L¦Cªí®æ")
  9.     Loop Until ¦L¦C = "1" Or ¦L¦C = "2" Or ¦L¦C = ""
  10.     If ¦L¦C = "1" Then
  11.         With Sh
  12.             .PageSetup.PrintArea = Rng.Address
  13.             .PageSetup.FitToPagesTall = 1
  14.             .PageSetup.FitToPagesWide = 1
  15.             .PrintOut
  16.         End With
  17.     ElseIf ¦L¦C = "2" Then
  18.         ¤G±iªí®æ
  19.     End If
  20. End Sub
  21. Private Sub ¤G±iªí®æ()
  22.     Dim R As Range, ActionShape As String, i As Integer
  23.     With Sh
  24.         ActionShape = .Shapes(Application.Caller).Name  '°õ¦æ¦¹µ{¦¡ªº«ö¶s¦WºÙ
  25.         '---¦¹¦æµ{¦¡½X «öF5 ©Î F8 ·|¦³¿ù»~  »Ý¬O¦b¤u§@ªí«ö¤U [«ö¶s] °õ¦æ ----
  26.         Application.ScreenUpdating = False
  27.         Rng.Copy Rng.Offset(Rng.Rows.Count)             '½Æ»sªí®æ
  28.         For Each R In Rng.Rows            '
  29.             R.Offset(20).RowHeight = R.RowHeight        '½Æ»sªí®æ:½Õ¾ã¦C°ª»Pªí®æ ¬Û¦P
  30.         Next
  31.         .PageSetup.PrintArea = .Range(Rng, Rng.Offset(Rng.Rows.Count)).Address
  32.                                                         '³]©w¦L¦C½d³ò
  33.         .PageSetup.FitToPagesTall = 1
  34.         .PageSetup.FitToPagesWide = 1
  35.         '.PrintPreview                                  '¦L¦C¹wÄý
  36.         .PrintOut                                       '¦L¦C
  37.         For i = .Shapes.Count To 2 Step -1              '§R°£¹Ï¤ù:¤ù¥Ñ«á§R°£¨ì²Ä2­Ó
  38.             If .Shapes(i).Name <> ActionShape Then .Shapes(i).Delete
  39.                                                         '±Æ°£Shape¬O«ü©wµ{¦¡«ö¯ÃªºShape
  40.         Next
  41.         Rng.Offset(Rng.Rows.Count).Clear                '²M°£: ½Æ»sªí®æ
  42.         Rng.Offset(Rng.Rows.Count).RowHeight = .Cells(.Rows.Count).RowHeight
  43.                                                         '¦^´_¦C°ª
  44.         .PageSetup.PrintArea = Rng.Address              '¦^´_¦L¦C½d³ò
  45.         Application.ScreenUpdating = True
  46.     End With
  47. End Sub
½Æ»s¥N½X

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2012-8-24 10:40 ½s¿è

¦^´_ 5# dechiuan999
Caller ÄÝ©Ê  ¶Ç¦^Ãö©ó©I¥s Visual Basic ªº¸ê°T ¡C
½Ð¦b¤u§@ªí¤W³]¤@ª«¥ó(¹Ï¤ù, «ö¶s...) ¥¨¶°«ü¦V Ex_Caller
¤@¯ë¼Ò²Õªºµ{¦¡½X
  1. Option Explicit
  2. Sub Ex_Caller()
  3. The_Caller Application.Caller
  4. End Sub
  5. Sub Auto_Open() '¦sÀÉ«á: ¶}Àɮɦ۰ʱҰʪº¥¨¶°
  6. The_Caller "Auto_Open"
  7. End Sub
  8. Sub Auto_CLOSE() 'ÃöÀɮɦ۰ʱҰʪº¥¨¶°
  9. The_Caller "Auto_CLOSE"
  10. End Sub
  11. Function Ex() As String '¤u§@ªí¤W ¿é¤J¨ç¼Æ =Ex()
  12. Application.Volatile '(Ex") = False
  13. Ex = "Ex_Function"
  14. The_Caller "Function Ex()"
  15. End Function
  16. Sub The_Caller(Macro As String)
  17. Dim v As String
  18. Select Case TypeName(Application.Caller)
  19. Case "Range"
  20. '¦b³æ¤@Àx¦s®æ¤¤¿é¤Jªº¦Û­q¨ç¼Æ
  21. v = Application.Caller.Address
  22. Case "String" '--¶Ç¦^¥G¥s¦¹¥¨¶°ªºª«¦WºÙ ---
  23. 'Auto_Open¡BAuto_Close¡BAuto_Activate ©Î Auto_Deactivate ¥¨¶°
  24. v = Application.Caller
  25. Case "Error"
  26. '[¤u¨ã] ¥\¯àªí¤¤ªº [¥¨¶°] ¹ï¸Ü¤è¶ô¡A©Î¤W­z¤§¥~ªº¨ä¥L©I¥sªÌ #REF! ¿ù»~­È
  27. v = "Error"
  28. Case Else
  29. v = "unknown"
  30. End Select
  31. MsgBox Macro & Chr(10) & "Caller = " & v
  32. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¯¸¦b¥b¸ô¡A¤ñ¨«¨ì¥Ø¼Ð§ó¨¯­W¡C
ªð¦^¦Cªí ¤W¤@¥DÃD