- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¦^´_ 6# et010884 - Option Explicit
- Dim WordÀÉ As String '¶×¥XwordÀÉ,¦sÀɪº¦WºÙ
- Dim ¬ö¿ý As Range
- Sub ¶×¥Xword() '¥Ñ²M³æ½Æ»s«á¶×¥XwordÀÉ
- Set ¬ö¿ý = Sheets("¬ö¿ý").[c2:m2]
- MsgBox Application.CountA(¬ö¿ý)
- If Application.CountA(¬ö¿ý) <> 11 Then
- MsgBox "¸ê®Æ¤£»ô¥þ": Exit Sub
- Else
- Do
- WordÀÉ = Application.InputBox("*.doc", "¶×¥XwordÀÉ,¦sÀɪº¦WºÙ")
- Loop While WordÀÉ = "False" Or WordÀÉ = ""
- If Not InStr(LCase(WordÀÉ), "*.doc") Then WordÀÉ = WordÀÉ & ".doc"
- End If
- Main
- ²M³æÀˬd
- End Sub
- Sub ²M³æÀˬd() 'Àˬd¬ö¿ý¤£¦s¦b: ¸ß°Ý¬O§_¥[¤J
- Dim R As Integer, E As Range, MM As String
- Set ¬ö¿ý = Sheets("¬ö¿ý").[c2:m2]
- With Sheets("²M³æ")
- R = .Cells(.Rows.Count, "c").End(xlUp).Row '²M³æ:¬ö¿ýªº¦C¼Æ
- If R = 1 Then
- GoTo OK
- Else
- MM = Join(Application.Transpose(Application.Transpose(¬ö¿ý.Value)), vbLf)
- For Each E In .Range("C2:M2").Resize(R - 1).Rows
- If MM = Join(Application.Transpose(Application.Transpose(E.Value)), vbLf) Then GoTo EE
- Next
- End If
- OK:
- If MsgBox(MM, vbYesNo, "°O¿ý: ¦s¤J²M³æ..") = vbYes Then
- ¬ö¿ý.Copy .Cells(R + 1, "c") '½Æ»s¨ì¬ö¿ýªº¦C¼Æ+1
- .Cells(R + 1, "B").NumberFormatLocal = "@"
- .Cells(R + 1, "B").FormulaR1C1 = Format(R + 1, "000")
- End If
- EE:
- ¬ö¿ý.EntireRow = "" 'Âà´««á°O¿ý¶±ªº¸ê®Æ²MªÅ
- End With
- End Sub
- Sub ½Æ»s¨ì¬ö¿ý()
- Dim Rng As Range
- With Sheets("²M³æ")
- Set Rng = .Range("a1").CurrentRegion.Rows(2)
- Set Rng = Rng.Resize(.Range("a1").CurrentRegion.Rows.Count - 1)
- If Not Application.Intersect(Rng, ActiveCell) Is Nothing Then
- .Range("A" & ActiveCell.Row & ":" & "M" & ActiveCell.Row).Copy Sheets("¬ö¿ý").Range("A2")
- MsgBox "½s¸¹: " & vbTab & "[" & .Range("B" & ActiveCell.Row) & "]", , "½Æ»s¨ì¬ö¿ý!!"
- Else
- MsgBox "»Ý¿ï¾Ü¦b ²M³æªº½d³ò"
- Rng.Select
- End If
- End With
- End Sub
- Private Sub Main() '°O¿ý¶×¥X¨ìwordÀÉ
- With CreateObject("Word.APPLICATION")
- .Visible = True
- ' .Documents.Open ("\\Tctk0fi25\oqa_report$\04_²§±`³B²zªí³æ_R3\¤£¦X®æ³æ¶}¥ß°Ï\1.doc")
- .Documents.Open (ThisWorkbook.Path & "\1.doc")
- With .ActiveDocument.Tables(1) 'WordÀɮפ¤²Ä¤@Óªí®æ
- ' .Cell(2, 1) = Rng(1, 1) '¶µ¦¸
- '.Cell(2, 2) = Rng(1, 2) '½s¸¹
- .Cell(2, 2) = ¬ö¿ý(1, 1) 'µo¦æ¤é´Á
- .Cell(2, 3) = ¬ö¿ý(1, 2) 'Product code
- .Cell(2, 4) = ¬ö¿ý(1, 3) '«È¤á
- .Cell(2, 5) = ¬ö¿ý(1, 4) 'Product code
- .Cell(2, 6) = ¬ö¿ý(1, 5) 'Lot id
- .Cell(2, 7) = ¬ö¿ý(1, 6) 'line
- .Cell(2, 8) = ¬ö¿ý(1, 7) 'Qty
- .Cell(4, 2) = ¬ö¿ý(1, 8) '¤º®e
- .Cell(5, 3) = ¬ö¿ý(1, 9) '¦¬¥ó¤é´Á
- .Cell(5, 7) = ¬ö¿ý(1, 10) '®Ö¹ï¤H
- .Cell(9, 4) = ¬ö¿ý(1, 11) 'Detail Explain
- '.Cell(?, ?)= ¾ºÙ ,¦~¸ê , ¬ö¿ý, ±½ÍªÌ:¾l¤U¸ê®Æ½Ð¦Û¦æ¶ñ¤J
- End With
- .ActiveDocument.SaveAs Filename:="D:\TEST\" & WordÀÉ '*** WORD¶×¥X ***
- .ActiveDocument.Close 'Ãö³¬wordÀÉ 'True
- .Quit 'Ãö³¬wordÀ³¥Îµ{¦¡
- End With
- End Sub
½Æ»s¥N½X |
|