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

Excel Vba©I¥soutlook±H«Hªº¤Þ¥Î°ÝÃD

Excel Vba©I¥soutlook±H«Hªº¤Þ¥Î°ÝÃD

¤j®a¦n
·Q½Ð°Ý ¦bexcel vba¤¤©I¥soutlook±H«H®É
¥²¶·­n¤â°Ê¤Þ¥Îoutlook object library
§Ú¦bA¹q¸£½s¼gexcel ¤¤ªºvba®É ¦³¤â°Ê¤Þ¥Îoutlook object library
¦ý·í§Ú§âÀÉ®×®³¨ìB¹q¸£®É ´N¥X²{¿ù»~ ¥²¶·­n¦A­«·s¤â°Ê¤Þ¥Îoutlook object library
¤~¥i¥H¥¿±`±H«H
·Q½Ð°Ý¦³¤°»ò¤èªk ª½±µ§â outlook object library ¥]¸Ë¦bvba¸Ì­±¡H
ÁÂÁÂ

¥»©«³Ì«á¥Ñ ciboybj ©ó 2019-8-1 23:50 ½s¿è

¦bVBA¤¤¤]¦³«e´Á¸j©w(Early binding)¤Î«á´Á¸j©w(Late binding)ªº¤£¦P
¨âªÌªºÀu¯ÊÂI¥i¥H°Ñ¦Ò¥H¤Uºô¯¸ªº¤¶²Ð
https://wordmvp.com/FAQs/InterDev/EarlyvsLateBinding.htm

­Y¬O¨Ï¥Î«á´Á¸j©w (Late Binding )«h¥i¥H¤£¥Î¤â°Ê¤Þ¥Î¬Û¹ïÀ³ªºobject library

¤]´N¬O»¡¡A¦b2010ª©Office¤¤¼g¦nªºVBAÀɮסA®³¨ì¤£¦Pªº¹q¸£¡A§Q¥Î2013ª©Office¶}±Ò®É¡AVBAµ{¦¡À³¸ÓÁÙ¬O¥i¥H¹B§@¡C

¬Û¹ïªº¡A­YVBA¬O¥Î«e´Á¸j©w(Early binding) ¡A¦b¤£¦Pª©¥»OfficeªºÀô¹Ò¤U¡A«Ü¦³¥i¯à·|µLªk¥¿±`¨Ï¥Î¡A¥²¶·­n¤â°Ê¤Þ¥Î¥¿½Tª©¥»ªºobject library¡C

¦ý¬O§Q¥Î«á´Á¸j©w·|¦³¤@¨Ç»yªk¬OµLªk³Q½sĶ¾¹¿ëÃÑ¡A¦]¦¹­n¦Û¤v¬d¥X¹ïÀ³ªº¼Æ¦r¡C
¥H¤U¬O¤@­Ó§Q¥ÎExcel ¶}±Ò¦P¸ê®Æ§¨¤¤ªº Word¡]¦¹Word¦³¤@­Ó¨âÄ檺ªí®æ ¨ä¤¤¤@Äæ¼g¦³XXX¡^
  1. Private Sub test()

  2.     Dim path As String
  3.     path = ThisWorkbook.path & "\test.docx"

  4.         Dim WordApp As Object
  5.         Set WordApp = CreateObject("Word.Application")
  6.         
  7.         With WordApp
  8.             .Visible = True
  9.             .Documents.Open path
  10.             .Activate
  11.             .Selection.homekey Unit:=6 'late binding ¥²¶·­n¥Î¼Æ¦r6ªí¥Ü ¤£¯à¥Î wdStory
  12.         End With
  13.         
  14.         WordApp.Documents.Open path
  15.         WordApp.Visible = True 'New Apps will be hidden by default, so make visible
  16.         
  17.         WordApp.Selection.Find.Execute FindText:="XXX"
  18.         WordApp.Selection.Move Unit:=12, Count:=1  'late binding ¥²¶·­n¥Î¼Æ¦r12ªí¥Ü ¤£¯à¥Î wdCell
  19.         WordApp.Selection.InsertAfter "OOO"
  20.         WordApp.Documents.Save

  21. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : §g¤l¦p¤ô¡AÀH¤è´N¶ê¡AµL³B¤£¦Û¦b¡C
ªð¦^¦Cªí ¤W¤@¥DÃD