如体,俺
Dim WordApp As New Word.Application
Dim wDoc As Document
Dim wTable As Word.Table
Set wDoc = WordApp.Documents.Open("D:\MyDOC\word1.doc")
Set wTable = wDoc.Tables(1) '取第一个表格
-> ........................ '如何wTable.cell(2,2) 赋值
Dim WordApp As New Word.Application
Dim wDoc As Document
Dim wTable As Word.Table
Set wDoc = WordApp.Documents.Open("D:\MyDOC\word1.doc")
Set wTable = wDoc.Tables(1) '取第一个表格
-> ........................ '如何wTable.cell(2,2) 赋值
wTable.Cell(2, 2).Range.Text ="xxxx"
Dim MyDoc As Document
Dim MyRange As RangePrivate Sub Command1_Click()
Debug.Print "----------------"
Debug.Print "最大列数:", MyDoc.Tables(1).Range.Information(wdMaximumNumberOfColumns)
Debug.Print "最大行数:", MyDoc.Tables(1).Range.Information(wdMaximumNumberOfRows)
Debug.Print "表格单元格总数:", MyDoc.Tables(1).Range.Cells.Count
'Debug.Print "", MyDoc.Tables(1).Columns.Count
'Debug.Print "", MyDoc.Tables(1).Rows.Count
Debug.Print "是否规则:", MyDoc.Tables(1).Uniform
'Debug.Print "", MyDoc.Tables(1).Range.Information
Dim i As Integer
i = 0
For i = 1 To MyDoc.Tables(1).Range.Cells.Count
Debug.Print "Cell " & i, _
"行" & MyDoc.Tables(1).Range.Cells(i).RowIndex, _
"列" & MyDoc.Tables(1).Range.Cells(i).ColumnIndex, _
"高:" & MyDoc.Tables(1).Range.Cells(i).Height, _
"宽:" & MyDoc.Tables(1).Range.Cells(i).Width, _
"高的类型:" & MyDoc.Tables(1).Range.Cells(i).HeightRule
MyDoc.Tables(1).Range.Cells(i).Range.Text = MyDoc.Tables(1).Range.Cells(i).RowIndex & "," & MyDoc.Tables(1).Range.Cells(i).ColumnIndex
Next i
End SubPrivate Sub Command2_Click()
Debug.Print wdRowHeightAtLeast
Debug.Print wdRowHeightAuto
Debug.Print wdRowHeightExactly
End SubPrivate Sub Command3_Click() Dim i As Integer
Debug.Print "-----------------------"
i = 1
For i = 1 To MyDoc.Shapes.Count
MyDoc.Shapes(i).Select
Selection.ShapeRange.RelativeVerticalPosition = wdRelativeVerticalPositionPage
Selection.ShapeRange.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
Debug.Print MyDoc.Shapes(i).Name, "相对页的水平位置:" & Selection.Range.Information(wdHorizontalPositionRelativeToPage), "相对页的垂直位置:" & Selection.Range.Information(wdVerticalPositionRelativeToPage), Selection.ShapeRange.Top, Selection.ShapeRange.Left
MyDoc.Shapes(i).TextFrame.TextRange.Text = MyDoc.Shapes(i).Name
Next i
End SubPrivate Sub Command4_Click()
Dim ra As Range
Dim ra_1 As Range
Dim ra_2 As Range
AppWord.Visible = True
MyDoc.Select
Set ra = Selection.Range
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="2"
Selection.Select
Set ra_1 = Selection.Range
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="3"
Selection.Select
Set ra_2 = Selection.Range
ra.Start = ra_1.Start
ra.End = ra_2.End
ra.Select
Selection.Copy
'ra.Copy
Documents.Add
Selection.PasteEnd SubPrivate Sub Form_Load()
Set MyDoc = AppWord.Documents.Open(App.Path + "\doc1.doc")
Debug.Print "打开文件!"
End SubPrivate Sub Form_Unload(Cancel As Integer)
MyDoc.Close
AppWord.Quit False
Debug.Print "程序退出!"
End Sub