达人进来帮忙吖,我的操作word语句有一个地方运行不过去,搞不懂了

aspvbjava 2003-05-19 11:00:19
下面是 lxcc(虫莲) 达人给我的vb操作word代码,在word插入书签,然后写入文本,现在程序运行到
iCount = lvCase.ListItems.Count
的时候出现错误:要求对象。我不知道这句话什么意思,能给我解释一下吗?
谢谢谢!!!
急急急!!!


On Error Resume Next '忽略错误
Set appword = GetObject(, "Word.Application") '查找一个正在运行的Excel拷贝
If Err.Number <> 0 Then '如果 Excel 没有运行则
Set appword = CreateObject("Word.Application") '运行它
End If
Err.Clear '清除发生错误的 Err 对象
On Error GoTo 0 '保留普通错误进程

Dim dot As String
Dim doc As String

dot = App.Path & "\file report\上行公文.doc"
doc = App.Path & "\file report\temp.doc"
Dim i As Integer
Dim iCount As Integer

'下面一句就是运行出错误的地方

iCount = lvCase.ListItems.Count
For i = 1 To iCount
appword.Documents.Open FileName:=dot, _
ConfirmConversions:=False, ReadOnly:=True, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
WritePasswordDocument:="", WritePasswordTemplate:="", Format:= _
0
appword.Visible = True
appword.ActiveDocument.Close
appword.Documents.Add Template:=dot, NewTemplate:=False
With appword.Application
.Selection.GoTo Name:="BM_WFWH" '书签名称,以下类似
.Selection.TypeText Text:=lvCase.ListItems.Item(i).SubItems(2)

.Selection.GoTo Name:="BM_SQH"
.Selection.TypeText Text:=lvCase.ListItems.Item(i).SubItems(1)

.Selection.GoTo Name:="BM_SQDate"
.Selection.TypeText Text:=Format(lvCase.ListItems.Item(i).SubItems(3), "long date")

.Selection.GoTo Name:="BM_ZLMC"
.Selection.TypeText Text:=lvCase.ListItems.Item(i).SubItems(4)

.Selection.GoTo Name:="BM_SQR"
.Selection.TypeText Text:=lvCase.ListItems.Item(i).SubItems(5)


'.ActiveDocument.PrintPreview
End With
ActiveDocument.SaveAs FileName:=doc, FileFormat:=wdFormatDocument, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False

appword.ActiveDocument.PrintOut FileName:=doc, Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=2, Pages:="", PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
appword.ActiveDocument.Close
Next
...全文
12 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
aspvbjava 2003-05-20
吧后面的参数都去掉,搞定了,谢谢吖
回复
aspvbjava 2003-05-20
刚才运行到
appWord.ActiveDocument.PrintOut FileName:=doc, Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=2, Pages:="", PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0

错误提示:未找到命名参数
另外当我敲入appWord.的时候后边没有弹出属性菜单,请问怎么回事儿啊?
谢谢吖
回复
aspvbjava 2003-05-20
哦,和和,谢谢,我去试试
回复
lxcc 2003-05-20
for
next
删掉
对listview内的数据循环,如果你没有就删掉
回复
lxcc 2003-05-20
lvcase是一个listview
回复
lxcc 2003-05-20
删掉,笔误!
回复
相关推荐
发帖
VB基础类
创建于2007-09-28

7490

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2003-05-19 11:00
社区公告
暂无公告