使用word文档的对象

时间:2013-08-30 14:52:53

标签: vb6 automation ms-word

我需要按照以下顺序在.doc上放置三个对象:

  • One Picutre;
  • Some Text;
  • One Table;

我最近学会了如何将图像放在我想要的位置(文档的顶部) 但现在,该表正在文本的中间,我如何设置文本Position Absolute,然后Table下面的text

我目前的代码:

Private Sub Command1_Click()
Dim Word_App            As Word.Application
Dim Word_Doc            As Word.Document
Dim Word_Table          As Word.Table
Dim Word_Range          As Word.Range
Dim iCount              As Integer

'Insert the image
Word_App.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Word_App.Selection.InlineShapes.AddPicture FileName:="C:\p\53.jpg", SaveWithDocument:=True
Word_App.Selection.TypeParagraph

With Word_App
   'Here I place some text
End With

'Insert Table
Set Word_Table = Word_Doc.Tables.Add(Range:=Word_Doc.Range(Start:=20, End:=20), NumRows:=3, NumColumns:=4, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
        wdAutoFitFixed)

Word_Doc.SaveAs FileName:="C:\p\TestandoPicture"
Set Word_Table = Nothing
Set Word_App = Nothing
Set Word_Doc = Nothing
End Sub

以下是结果示例: Example http://i39.tinypic.com/29njpqw.jpg

Notice that:在我的代码中,我输入了我的表Start:=20, End:=20的位置,并且它处于第20个字符的位置...但我想将它放在文本下面... Wich这是最好的方法吗?

1 个答案:

答案 0 :(得分:0)

突出显示文字,对突出显示的文字进行字数统计,然后使用其中的字符数来定位表格。粗暴但有效。

相关问题