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

[°ÝÃD]¦p¦ó¬O¥Î¥t¥Î¤@­Óexcel fileªº¥¨¶°¡A¦Ó¤£»Ý­n¶}±Ò¦¹excel file

[°ÝÃD]¦p¦ó¬O¥Î¥t¥Î¤@­Óexcel fileªº¥¨¶°¡A¦Ó¤£»Ý­n¶}±Ò¦¹excel file

¥»©«³Ì«á¥Ñ jarodz ©ó 2012-1-4 00:17 ½s¿è

¦]¬°¤p§Ì¼g¤F¤@¨Ç VBA ªº¥¨¶°¤À¨Éµ¹¦P¨Æ¨Ï¥Î¡A
¤@¶}©l¬O©ñ¦b¤@­Óexcel¡A­n¥Îªº¤H¥hcopy³o­Óexcel file¨Ó¥Î¡A
¦ý¬OÀHµÛ¨Ï¥Î¤H¼Æ¤Î¦¸¼ÆÅܦh¡A¥[¤W¤¤³~¦³§ïª©¡A²{¦bÅܦ¨¦n´X­ÓÀɮצn´X­Óª©¥»¡A
®`§Ú¦Û¤v³£§Ñ¤F­þ­Ó¬O³Ì·sª©¡A¤U¦¸­n±q­þ­Ó§ï°_¡C
«á¨Óµo²{¥i¥H§@­Ó«ö¶s¥hcall¦P¤@­Óexcel¸Ìªº¥¨¶°¡A
¦ý¬O¹J¨ì¤@­Ó°ÝÃD¡A¬O¨C¦¸°õ¦æ³£·|§â³o­Ó¦@¥Îªºexcel¶}°_¨Ó¡A
¦³¨S¦³¿ìªk¥i¥H¤£Åý¥L¶}°_¨Ó©ÎÁôÂð_¨Ó¥B¤£·|§âÀÉ®×Âꦨ°ßŪ¡C
ÁÂÁ¦^µª¡C

¤@­Ó¹ïexcel¾Þ§@¤£¼ôªºµ{¦¡¤H¯d¡C

¥»©«³Ì«á¥Ñ GBKEE ©ó 2011-12-22 16:36 ½s¿è

¦^´_ 1# jarodz
¥[¤J¤@¯ë¼Ò²Õ ¦WºÙ¬°"Module1"  Àɮ׶}±Ò«á¦Û°Ê°õ¦æAuto_Openµ{§Ç  ¥t¦sÀɮצWºÙ, ­ìÀÉ®×´N¤£·|¶}±Ò.
  1. Option Explicit
  2. Private Sub Auto_Open()
  3.     ThisWorkbook.SaveAs CurDir & "\" & Split(ThisWorkbook.Name, ".")(0) & "³Æ¥÷"    '¥t¦sÀɮצWºÙ
  4.     With ThisWorkbook.VBProject
  5.         .VBComponents.Remove .VBComponents("Module1")    ' §R°£  Module1 ¼Ò²Õ
  6.     End With
  7. End Sub
½Æ»s¥N½X

TOP

¦^´_ 2# GBKEE


Dear GBKEE,

ÁÂÁ§Aªº¦^µª¡A
¤£¦n·N«ä¡A¥i¯à¬O§Ú­ì¥ýªº·N«ä´y­zªº¤£²M·¡¡A
§Ú·Q§@ªº¬OÃþ¦ü¼W¯q¶°¡A(§Ú¤w¸gª¾¹D¦p¦ó§â¤@¯ëxls§Ë¦¨¼W¯q¶°)
¦ý¤£ª¾¦p¦ó¦b·s«Øªºexcel¤¤ call ³o­Ó¼W¯q¶°¸ÌªºSub routine?

³Ì²×§Ú¬O§Ë¦¨,ÂIÀ»¦¹excel¼W¯q¶°·|¦Û°Ê¦b¤u¨ã¦C¼W¥[«ö¶s¡A
«ö¦¹«ö¶s´N·|°õ¦æexcel¼W¯q¶°¤¤ªºsub routine.

ÁÂÁ¡C

BR,
Jarod

TOP

¦^´_ 3# jarodz
§Ú·Q§@ªº¬OÃþ¦ü¼W¯q¶°¡A(§Ú¤w¸gª¾¹D¦p¦ó§â¤@¯ëxls§Ë¦¨¼W¯q¶°) ¦ý¤£ª¾¦p¦ó¦b·s«Øªºexcel¤¤ call ³o­Ó¼W¯q¶°¸ÌªºSub routine
Run "³o­Ó¼W¯q¶°!routine"

TOP

¦^´_ 4# GBKEE

²{¦b¦³­Ó°ÝÃD,
¦b¹w³Æ§â§@¦¨¼W¯q¶°«eªºxls§@¤@­Ó¤u¨ã¦Cªºbutton¡Aassign ³o­Óxls¸Ìªºmacro µ¹¥¦¡A
µM«á¦A§â IsAddin Äݩʳ]¬° true ¡A«áÀx¦s¡C

¦b¥t¥~¤@¥x¶}±Ò¦¹ xls¡A¦¹¼W¥[ªºbuttonµLªk¥X²{¡A
¦n¹³¬OµLªk¬Ý¨ì¼W¯q¶°¸Ìªºsub routine.
³o¦ó¸Ñ?

¦P¼Ëªº°ÝÃD¡Axls³]¬°¼W¯q¶°«á¦bmacro list´N¬Ý¤£¨ì¨ä Macro¡A
¬Ý¤£¨ìÁÙ¬O¥i¥H°õ¦æ¶Ü?

BR,
Jarod

BR,
Jarod

TOP

¦^´_ 5# jarodz
½Æ»s¨ì¤@¯ë¼Ò²Õ¤¤
  1. Private Sub Auto_Open()
  2.     Dim newcontrl As CommandBarControl
  3.     Application.CommandBars.ActiveMenuBar.Reset
  4.       Set newcontrl = Application.CommandBars.ActiveMenuBar.Controls.Add(10)
  5.         With newcontrl
  6.         .Caption = "±±¨î¶s"
  7.     End With
  8.     Set A = newcontrl.Controls.Add(1)
  9.             A.Caption = "¥»¾÷¨Ï¥ÎªÌ"
  10.             A.OnAction = "EX"
  11.      Set A = newcontrl.Controls.Add(1)
  12.             A.Caption = "¥»¾÷¸ê°T"
  13.             A.OnAction = "EX1"
  14. End Sub
  15. Private Sub Auto_Close()
  16.     Application.CommandBars.ActiveMenuBar.Reset
  17. End Sub
  18. Private Sub Ex()
  19.     MsgBox "¨Ï¥ÎªÌ : " & Application.UserName
  20. End Sub
  21. Private Sub Ex1()
  22.     MsgBox "Welcome to Microsoft Excel version " & _
  23.     Application.Version & " running on " & _
  24.     Application.OperatingSystem & "!"
  25. End Sub
½Æ»s¥N½X

TOP

Dear GBKEE,

ÁÂÁ¡A·Q¦A½Ð±Ð¤@¤U¥Î Auto_Open ¸ò¼g¦b ThisWorkbook ¥Î Workbook_Open() ¦³¤°»ò®t§O¡A
¦AªÌ°£¤F Auto_Open, Auto_Close ¤§¥~¡A¦b¤@¯ëÁÙ¦³¤°»ò¯S®íªº event ¥i¥H trap ¨ì¡A
³o­n¥Î¤°»òÃöÁä¦r¬d help ©Î¥h­þ¸Ì¥i¥H¬Ý¨ì³o¨Ç event list¡AÁÂÁ¡C

BR,
Jarod

TOP

¦^´_ 7# jarodz
Workbook_Open() ¬OThisWorkbookªº¹w³]¨Æ¥ó  Àu¥ý   Auto_Open() ( ©ó¤@¯ë¼Ò²Õ )
¨ä¥L¹w³]¨Æ¥ó ¦p¹Ï:

TOP

Dear GBKEE
WorkBook_Open() ¥i¥H«Üª½Ä±ªºµo²{¤F¡A
¦ý¬O Auto_Open()³o­Ó¬O¥h­þ¸Ì¬d¨ìªº?
§Ú·Q°Ýªº¬O¤@¯ëmodule¥i¥H¥Îªºevent­n¥h­þ¬d?
Auto_Open() ¦bIDEªºµøµ¡¤¤¤£¹³WorkBook_Open()·|¦Û°Ê¦C¥X¨Ó¡C

BR,
Jarod

TOP

¦^´_ 9# jarodz
¤@¯ëmodule¥i¥H¥Îªºevent
´NAUTP_OPEN , AUTO_CLOSE ³o2­Ó,¦pªGÁÙ¦³½Ðª¾¹Dªº¤À¨É,

TOP

        ÀR«ä¦Û¦b : ¥Í®ð¡A´N¬O®³§O¤Hªº¹L¿ù¨ÓÃg»@¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD