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

¥Îexcel vba ±±¨îword ¨Ã±Nuserformªº¸ê®Æ¶ñ¤Jwordªºªí®æ¤¤

¥Îexcel vba ±±¨îword ¨Ã±Nuserformªº¸ê®Æ¶ñ¤Jwordªºªí®æ¤¤

¥»©«³Ì«á¥Ñ ciboybj ©ó 2019-7-30 22:25 ½s¿è

¤j®a¦n:)
§Ú¼g¤F¤@­Ó¤pµ{¦¡¦bExcel VBA¤¤
¥D­n¬O¦³¤@­ÓUserform ¸Ì­±¦³¤@­Ó¡y«ö¶s¡z¡A¨Ï¥ÎªÌ«ö¤U¡y«ö¶s¡z«á
vba·|¶}±Ò¦P¤@¸ô®|¤U¦W¬°¡y½d¥»¡zªºwordÀÉ
¶}±ÒwordÀÉ«á¡A±N´M§ä wordÀɮפ¤ªº¡y ½s¸¹¡z ¦r¦ê¡A§ä¨ì¡y ½s¸¹¡z ªº¦r¦ê«á¡A¦V¥kÃä²¾°Ê¨â­Ó¦r¤¸(²¾¨ì¹j¾Àªº®æ¤l¤¤)¡A¨Ã´¡¤Juserform¤¤¬Y¤@­Ó¼Ð¶¡ªº¦r¦ê
  1. Private Sub CommandButton2_Click()

  2.     Dim path As String
  3.     path = ThisWorkbook.path & "\½d¥».docx"
  4.     'Debug.Print (path)

  5.     Set WordApp = CreateObject("Word.Application")
  6.     WordApp.Documents.Open (path)
  7.     WordApp.Visible = True
  8.     WordApp.Activate
  9.     WordApp.Selection.homekey unit:=6
  10.    
  11.     WordApp.Selection.Find.Execute FindText:="½s¸¹" ', Forward:=True, Wrap:=wdFindStop
  12.     WordApp.Selection.MoveRight = 2
  13.     WordApp.Selection.InsertAfter = LB_Num.Caption
  14.    
  15. End Sub
½Æ»s¥N½X
¦ý¬O¡A§Ú°õ¦æ¤W­±ªºµ{¦¡½X«á¡A¥X²{¤F¥H¤Uªº¿ù»~°T®§
¿ù»~°T®§.PNG

·Q½Ð°Ý¤j®a
¬°¦ó¦³¤W­±ªº¿ù»~°T®§ §Ú­n«ç»ò­×§ïµ{¦¡¤~¥i¥H¹B§@ªü¡ã¡ã¡ã{:3_50:}
test.rar (31.64 KB)

¥Ø«e§ä¨ìªº¸Ñ¨M¤è¦¡¬O¡G
¦bvbaªº¤u¨ã¦C¤¤¿ï¾Ü¡y¤u¨ã¡z->¡y³]©w¤Þ¥Î¶µ¥Ø¡z
§âMicrosoft Word ªº¶µ¥Ø¤Ä°_


µ{¦¡½Xªº³¡¤À¦p¤U¡G
  1. Private Sub CommandButton1_Click()
  2.    
  3.    Dim str As String
  4.     str = TextBox1.Text

  5.     Dim WordApp As Word.Application
  6.     Set WordApp = New Word.Application

  7.     WordApp.Documents.Open ThisWorkbook.Path & "\test.docm"
  8.     WordApp.Visible = True
  9.    
  10.     WordApp.Selection.Find.Execute FindText:="½s¸¹"
  11.     WordApp.Selection.Move Unit:=wdCell, Count:=1
  12.     WordApp.Selection.InsertAfter str
  13.     WordApp.Documents.Save
  14.    
  15.     Set WordApp = Nothing
  16. End Sub
½Æ»s¥N½X
¥Ñ©ó¦bword¤¤§ä¨ìªº¦r¬O¦bªí®æ¤¤¡A¦]¦¹¡A­n¥ÎwdCell ³o­Ó²¾°Ê³æ¦ì¨Ó²¾°Ê¹«¼Ð¦ì¸m

TOP

        ÀR«ä¦Û¦b : µoµÊ®ð¬Oµu¼ÈªºµoºÆ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD