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

[Âà¶K] VBA-¨ú¥N¤é´Á®æ¦¡

[Âà¶K] VBA-¨ú¥N¤é´Á®æ¦¡

¥»©«³Ì«á¥Ñ °¶ÔÐ ©ó 2010-6-30 23:10 ½s¿è

­ìµoªíªÌ¡Gleonchou (2005-03-05)

°ÝÃD¡G¦bword¦p¦ó±N¤¤¤å¤é´ÁÂনªü©Ô§B¼Æ¦rªº¤é´Á®æ¦¡?
¦p: ¤@¤E¤E¥|¦~¤C¤ë¤@¹ï¤Ò°ü
ÅÜ: 1994¦~7¤ë¤@¹ï¤Ò°ü

­±¹ï³o°ÝÃD¥i¯à«Üª½Ä±´N·Q¨ì [·j´M/¨ú¥N] ªº¤è¦¡¡C
¦ý¦pªG¬O¤Ö¼Æ´X­Ó¤é´Á¡AÁÙ¥i¤@­Ó¤@­Ó¨ú¥N¡A§_«h±q¡³~¤E¤À§O¨ú¥N¬°0~9­n¾Þ§@¤Q¦¸¡A¦Ó¥BÁÙ¥i¯à¨ú¥N¨ì§OªºªF¦è (¨Ò¦p"¤@¹ï¤Ò°ü"ªº¤@)¡C
ÁöµMWord·j´M¥\¯à¤ä´©wildcard¡A¦ý¨ú¥N¥\¯àµLªkº¡¨¬¦¹°ÝÃDªº»Ý¨D(¾Ú§Ú©Òª¾,2000ª©)¡A©ó¬O¥¨¶°´N¬£¤W¥Î³õ¤F¡C

¸Õ¥Î¥H¤Uªº¥¨¶°¡AÀ³¥i¥H¬Ù¤£¤Ö¤O®ð¡G

µ{¦¡½X:
  1. Sub test()
  2. Selection.HomeKey Unit:=wdStory
  3. x = "[¤@¤G][¤E¡³][¤C¤K¤E¡³][¤@¤G¤T¥|¤­¤»¤C¤K¤E¡³]¦~*[¤@¤G¤T¥|¤­¤»¤C¤K¤E¤Q]¤ë"
  4. Do
  5. ¡@¡@Selection.Find.Execute x, MatchWildcards:=True
  6. ¡@¡@If Selection.Type = wdSelectionIP Then Exit Do
  7. ¡@¡@Selection.Text = Format(Selection.Text, "yyyy¦~m¤ë")
  8. ¡@¡@Selection.Collapse Direction:=wdCollapseEnd
  9. Loop
  10. End Sub
½Æ»s¥N½X
»¡©ú¡G
³o¬O¸U¥Î¦r¤¸(wildcard)ªºÀ³¥Î ¡A¥H¤é´Áªº¯S©Ê¨Ó¨M©wwildcard¥N½X«ç»ò¼g¡G
[¤@¤G][¤E¡³][¤C¤K¤E¡³][¤@¤G¤T¥|¤­¤»¤C¤K¤E¡³]¦~*[¤@¤G¤T¥|¤­¤»¤C¤K¤E¤Q]¤ë
¦pªG§A¤£¼ô¸U¥Î¦r¤¸¡A¥i¥ý§â¨C­Ó [ ] ¬Ý§@¤@­Ó¦r¡A[ ] ¸Ì­±¨C­Ó¦r²Å¦X¤å³¹¤ºªº´Nºâ¦¨¥ß¡C
³o­Ó¥N½X¥i¥H·j´M¨ì 1970~2099 ©Ò¦³¦~¤ëªº¤º®e¡A­Y¤£¨¬ÁÙ¥i½Õ¾ã¡C

¥¨¶°¥ý±N´å¼Ð²¾¨ì¤å¥ó¶}ÀY (HomeKey Unit:=wdStory)¡A±µµÛ¶] Do... Loop °j°é¡A³v¤@·j´M(Find.Execute)²Å¦X¤W­zwildcard±ø¥óªº¤º®e¡A
¦pªG§ä¨ì¡G
¿ï¨ú½d³ò(selection)·|¿ï¨ú§ä¨ìªº¤º®e(¸Ó¦~¤ë¤Ï¥Õ)¡Aµ{¦¡·|³z¹LFormat¨ç¼Æ±N¥¦¨ú¥N¬°ªü©Ô§B¼Æ¦rªº¤é´Á®æ¦¡¡AµM«á§ïÅÜ¿ï¨ú°Ï(Collapse)¨ì¸Ó¦~¤ë¤§«á¡A·Ç³Æ¤U¤@¦¸·j´M¡C
¦pªG§ä¤£¨ì¡G
¿ï¨ú½d³ò¤£·|§ïÅÜ¡A¤]´N¬OµL¥ô¦ó°Ï°ì¤Ï¥Õ (Selection.Type = wdSelectionIP)¡A¦¹®É´N¸õ¥X°j°é (Exit Do) ¨Ãµ²§ôµ{¦¡¡C

§Ú¥Îªº¬O2000ª©¡A¥u¯à·Q¨ì³o­Ó¤èªk...
¦pªG§Aª¾¹D·sª©¦³¬ÛÃöªº¥\¯à¡A©Î¦³¨ä¥L¤£¿ùªºÂI¤l¡AÅwªï¤À¨Éµ¹¤j®a®@
°¶Ôйq¤l®Ñ,Åwªï§K¶O¤U¸ü°Ñ¦Ò
http://www.twbts.com/ebook/?subject=office
http://www.twbts.com/ebook/?subject=soft
°¶ÔÐÂîѮw---https://www.facebook.com/groups/669579416484096/
¦³¤@®a¬a¥J©±---https://www.facebook.com/sadodona

        ÀR«ä¦Û¦b : ¦³¤ß´N¦³ºÖ¡A¦³Ä@´N¦³¤O¡A¦Û³yºÖ¥Ð¡A¦Û±oºÖ½t¡C
ªð¦^¦Cªí ¤W¤@¥DÃD