请先看代码,当点击Command1按钮的时候打开word程序和空白文档,当关闭WORD后再点击Command1时就会报错:“实时错误'462':远程服务器不存在或不能使用”,但如没有那个with wDoc块就不会报错,但我需要用with wDoc中的语句,请问哪位高手能解决,或告诉我是什么原因也行,谢谢 !
Dim wApp As Word.Application
Dim wDoc As Word.Document
Dim wSel As Word.Selection
Dim wTab As Word.TablePrivate Sub Command1_Click() Set wApp = New Word.Application
wApp.Visible = True
Set wDoc = wApp.Documents.Add
Set wSel = wApp.Selection
With wDoc.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientLandscape
.TopMargin = CentimetersToPoints(1)
End With
Exit Sub
Dim wApp As Word.Application
Dim wDoc As Word.Document
Dim wSel As Word.Selection
Dim wTab As Word.TablePrivate Sub Command1_Click() Set wApp = New Word.Application
wApp.Visible = True
Set wDoc = wApp.Documents.Add
Set wSel = wApp.Selection
With wDoc.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientLandscape
.TopMargin = CentimetersToPoints(1)
End With
Exit Sub
解决方案 »
- 第一,散分
- 非常菜的问题,怎么把PictureBox的规格设成象素格式?
- 求一代码 在线等待100分!
- 请问.怎样实现像MTV那样的字?具体如下.
- [求助] Setup Factory 设定文件夹访问权限
- 小问题,如何正确判断text控件中输入值的数据类型?TypeName 和varType怎么用?谢谢
- 轻松得分
- 请教iso是什么文件的扩展名,可以用什么文件打开?
- 如何在不确定列的情况下打印报表?
- C++程序调用VB编写的DLL,出错了,如何调试
- 帮忙分析一下源码
- 单击工具栏里面的添加窗体按钮时,弹出对话框, 可以正常添加新窗体, 但是当我添加“tip of the day"这种窗体时, 弹出一个错误的对话框
set wdoc=nothing
这样就可能解决问题
要不然.程序会长驻内存.
application.quit
set wdoc=nothing
With WodApp
.Visible = True
.Documents.Add
.......................
.Documents.Save
.Quit
End With