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

[µo°Ý] Ū¨úªí®æ

[µo°Ý] Ū¨úªí®æ

¥»©«³Ì«á¥Ñ kannas ©ó 2010-12-2 21:35 ½s¿è

½Ð°Ý¦p¦ó¥ÎExcel ªºVB¡A¼g¦¨Åª¨úwordªºªí®æ¡A
¨Ã§â¥¦ÂàÅܦbExcel¤W­±¡A®æ¦¡­n¸òword¤Wªº¤@¼Ë¡C


¬°¤°»òH¤j¥i¥H¦³³o¨Ç«ü¥O,¦ý§Ú¨S¦³?


Uploaded with ImageShack.us
80 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

¦^´_ 11# kannas
¦Ñ®L«e½úªºª«¥ó¥]¸Ë¤èªk¬O©p¸Ó¾Ç²ß¤è¦V
http://forum.twbts.com/viewthread.php?tid=782&extra=&highlight=word&page=1
°Ñ¦Ò¤§«eªº°Q½×¡A§A¹ïª«¥óÁpµ²ªº¤èªk·|¦³¸û¦hªº»{ÃÑ

³æ´NVBA»yªk°Q½×¡A§A©Ò´£¨ìªºjoin¤èªk
³o¬O¦r¦êªº³sµ²¨ç¼Æ¡A§A¥i°Ñ¦ÒVBA»¡©ú
´N¯àª¾¹D¦¹¨ç¼Æ¥Îªk¤Î¥Î³~
§A­n¥Î&¥N´ÀJOIN¨ç¼Æ·íµM¤]¦æ
¨º´N¬O¦b¨ú±oªí®æ¤ºªº¨C¤@¥y¦r¦ê¡A
¥Îmystr=mystr & chr(10) & Tb.Cell(i, j).Range.Sentences(s + 1)
  1. Sub WriteWordTb()
  2. Dim Tb As Table, Ar()
  3. Set Wd = CreateObject("Word.Application") '³Ð«ØWORDµ{¦¡ª«¥ó
  4. Cells.Clear '²MªÅ¤u§@ªí¤º®e
  5. With Wd 'Ãö©óWORDµ{¦¡ª«¥ó
  6.   With .Documents.Open(ThisWorkbook.Path & "\1.doc") '¶}±Ò«ü©wªºÀÉ®×
  7.     For Each Tb In .tables 'doc¤å¥ó¤¤ªº¨C­ÓTable
  8.     For i = 1 To Tb.Rows.Count
  9.         For j = 1 To Tb.Columns.Count
  10.            For s = 0 To Tb.Cell(i, j).Range.Sentences.Count - 1
  11.                 If mystr="" Then
  12.                 mystr=Tb.Cell(i, j).Range.Sentences(s + 1)
  13.                 Else
  14.                mystr= mystr & chr(10) & Tb.Cell(i, j).Range.Sentences(s + 1) '³s±µ¨C¥y
  15.                End If
  16.            Next
  17.         With Cells(i, j)
  18.         .Value = mystr 'Àx¦s®æªº­È
  19.          mystr=""   '§âÅܼÆÂk¹s
  20.         .WrapText = True  'Àx¦s®æ³]©w¦¨¦Û°Ê´«¦æ
  21.         End With
  22.         Next
  23.     Next
  24.     Next
  25.   End With
  26.   .Quit 'Ãö³¬µ{¦¡
  27. End With
  28. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

±Ë²¦Ó´NÁc

TOP

¦^´_ 10# Hsieh


½Ð°ÝJoinªºµ{¦¡¦³¿ìªk¥ÎAnd¨Ó¼g¶Ü?
§ÚÅ¥¤H»¡³o­Ó¤ñ¸û²³æ¡AJoin¬O¤ñ¸û°ª¶¥ªº¥Îªk
§Ú¤£©ú¥Õ¥ÎAnd¼gªº¸Ü¡A¬O­n­þ¨Ç±ø¥ó³sµ²­þ¨Ç±ø¥ó??

               ¡¯ReDim Preserve Ar(s)
               ¡¯Ar(s) = Tb.Cell(i, j).Range.Sentences(s + 1)
               
            Next
            
         ¡¯mystr = Join(Ar, Chr(10))
         ¡¯.Value = mystr
         ¡¯.WrapText = True
         
         End With
         
         Erase Ar


ÁÙ¦³¥i¥H¸ÑÄÀ¤W­±¦³¡¯ªºµ{¦¡·N«ä¶Ü?
§ÚÁöµM¤j·§ª¾¹D·N«ä¡A¦ý¦³¤H°Ý§Ú®É¡A§Ú¯uªºµLªk¹F¥X¨Ó¡C


³Â·Ð±z¤F  ÁÂÁÂ!

TOP

¥»©«³Ì«á¥Ñ Hsieh ©ó 2010-12-23 14:05 ½s¿è

©Ò¥H¡A©p¨Ã«D­nÅý¤å¦r¨Ì¾ÚWORDªí®æ¤º®e´«¦æ
¨º´N³]©wEXCEL¦Û°Ê´«¦C
  1. Sub WriteWordTb()
  2. Dim Tb As Table, Ar()
  3. Set Wd = CreateObject("Word.Application") '³Ð«ØWORDµ{¦¡ª«¥ó
  4. Cells.Clear '²MªÅ¤u§@ªí¤º®e
  5. With Wd 'Ãö©óWORDµ{¦¡ª«¥ó
  6.   With .Documents.Open(ThisWorkbook.Path & "\1.doc") '¶}±Ò«ü©wªºÀÉ®×
  7.     For Each Tb In .tables 'doc¤å¥ó¤¤ªº¨C­ÓTable
  8.     For i = 1 To Tb.Rows.Count
  9.         For j = 1 To Tb.Columns.Count
  10.            For s = 0 To Tb.Cell(i, j).Range.Sentences.Count - 1
  11.               ReDim Preserve Ar(s)
  12.               Ar(s) = Tb.Cell(i, j).Range.Sentences(s + 1)
  13.            Next
  14.          mystr = Join(Ar, Chr(10))
  15.         With Cells(i, j)
  16.         .Value = mystr
  17.         .WrapText = True
  18.         End With
  19.         Erase Ar
  20.         Next
  21.     Next
  22.     Next
  23.   End With
  24.   .Quit 'Ãö³¬µ{¦¡
  25. End With
  26. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 8# Hsieh


   ½Ð°Ý§Ú¥Î¤W­±¨º­Óµ{¦¡«á¡A¦]¬°¦³¨Çªí®æ¤º¥Lªº¦r¼Æ¦³ÂI¤p¦h¡A
  ¥Î¦Û°Ê½Õ¾ãÄæ¼eªº¸Ü¡A¾ã­Óªí®æ´N·|¯}Ãa±¼¡AÅܱo«Ü¼e¡C
  ¹³¬O¦³¤@¦ê¦r¡AÂI¤U®æ¤l¤º¥L·|Åã¥Ü¥þ³¡ªº¦r¡A¦pªG¨SÂI´N¥uÅã¥Üªí®æ¤j¤p©Ò¯àÅã¥Üªº¦r¼Æ¡A¨ä¥L«h¤£Åã¥Ü¡A
  ¥i¥H§â¥¦§Ë¦¨¹³¬O¦Û°Ê´«¦æ¶Ü?
   Åýªí®æ¬Ý°_¨Ó¤£·|«Ü©_©Ç?

   °Ý¤F³o»ò¦h  ¯u¬O³Â·Ð¦U¦ì¤F  ÁÂÁÂ!!!

TOP

¥»©«³Ì«á¥Ñ Hsieh ©ó 2010-12-23 14:19 ½s¿è

]¦^´_ 7# kannas


    ¶·¤Þ¥Î¶µ¥Ø
MicroSoft Word 12.0 Object Library

©Î¨ú®øTbÅܼƫŧi
  1. Sub WriteWordTb()
  2. Dim Ar()
  3. Set Wd = CreateObject("Word.Application") '³Ð«ØWORDµ{¦¡ª«¥ó
  4. Cells.Clear '²MªÅ¤u§@ªí¤º®e
  5. With Wd 'Ãö©óWORDµ{¦¡ª«¥ó
  6.   With .Documents.Open(ThisWorkbook.Path & "\1.doc") '¶}±Ò«ü©wªºÀÉ®×
  7.     For Each Tb In .tables 'doc¤å¥ó¤¤ªº¨C­ÓTable
  8.     For i = 1 To Tb.Rows.Count
  9.         For j = 1 To Tb.Columns.Count
  10.            For s = 0 To Tb.Cell(i, j).Range.Sentences.Count - 1
  11.               ReDim Preserve Ar(s)
  12.               Ar(s) = Tb.Cell(i, j).Range.Sentences(s + 1)
  13.            Next
  14.          mystr = Join(Ar, Chr(10))
  15.         Cells(i, j) = mystr
  16.         Erase Ar
  17.         Next
  18.     Next
  19.     Next
  20.   End With
  21.   .Quit 'Ãö³¬µ{¦¡
  22. End With
  23. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 6# Hsieh


    ³o­Óµ{¦¡µLªk°õ¦æ­C
   ¥¦Åã¥Ü½sĶ¿ù»~:  ¨Ï¥ÎªÌ¦Û­q«¬ºA©|¥¼©w¸q

TOP

¥»©«³Ì«á¥Ñ Hsieh ©ó 2010-12-17 15:54 ½s¿è

¦^´_ 5# kannas
  1. Sub WriteWordTb()
  2. Dim Tb As Table, Ar()
  3. Set Wd = CreateObject("Word.Application") '³Ð«ØWORDµ{¦¡ª«¥ó
  4. Cells.Clear '²MªÅ¤u§@ªí¤º®e
  5. With Wd 'Ãö©óWORDµ{¦¡ª«¥ó
  6.   With .Documents.Open(ThisWorkbook.Path & "\1.doc") '¶}±Ò«ü©wªºÀÉ®×
  7.     For Each Tb In .tables 'doc¤å¥ó¤¤ªº¨C­ÓTable
  8.     For i = 1 To Tb.Rows.Count
  9.         For j = 1 To Tb.Columns.Count
  10.            For s = 0 To Tb.Cell(i, j).Range.Sentences.Count - 1
  11.               ReDim Preserve Ar(s)
  12.               Ar(s) = Tb.Cell(i, j).Range.Sentences(s + 1)
  13.            Next
  14.          mystr = Join(Ar, Chr(10))
  15.         Cells(i, j) = mystr
  16.         Erase Ar
  17.         Next
  18.     Next
  19.     Next
  20.   End With
  21.   .Quit 'Ãö³¬µ{¦¡
  22. End With
  23. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

        ÀR«ä¦Û¦b : ¤@­Ó¯Ê¤fªºªM¤l¡A¦pªG´«¤@­Ó¨¤«×¬Ý¥¦¡A¥¦¤´µM¬O¶êªº¡C
ªð¦^¦Cªí ¤W¤@¥DÃD