|
各位大虾,本人希望通过word,把其中一个值附给excel的单元格
功能见解1,填好word,2,打开excel 3,找到制定单元格,4传递值 - - 但好像一些原来在excel里执行很好的代码现在写在word里就不管用了
What = InputBox("Input contract number")
Workbooks.Open Filename:= _
"Q:\REGISTER\CONTRACT REGISTER YTD 2006.xls"
Dim wb As Variant
Dim sht As Variant
Dim C As Range
wb = ActiveWorkbook.Name
i = 0
On Error Resume Next
For Each sht In ActiveWorkbook.Sheets
With Workbooks(wb).Sheets(sht.Name).UsedRange
Set C = .Find(What:=What, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, matchbyte:=False, SearchFormat:=False)
If Not C Is Nothing Then
MsgBox "Product Name:" & C.Offset(0, 5)
kkk = C.Offset(0, 11)
MsgBox "Ordered Date:" & kkk
IntervalMonth = DateDiff("m", kkk, Date)
MsgBox "Interval Month from Ordrd to Today:" & IntervalMonth
i = i + 1
End If
End With
Next
If i = 0 Then
MsgBox "Did not find the contract!"
End If
ActiveWorkbook.Close |
|