键入不匹配,尝试在Word 2007中使用SaveAs [英] Type Mismatch trying to using SaveAs with Word 2007

查看:103
本文介绍了键入不匹配,尝试在Word 2007中使用SaveAs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

显式选项

'脚本名称:passwordProtectWORD.vbs

' Script Name: passwordProtectWORD.vbs

'

'说明:密码​​保护文本文件中定义的WORD文件列表.文本文件必须包含WORD文件的完整路径.

' Description: Password protects a list of WORD files defined in a text file. The text file must contain the full path to the WORD file(s).

'文本文件格式示例:

''C:\ test \ test1.doc

'         C:\test\test1.doc

''C:\ test \ test2.doc

'         C:\test\test2.doc

''C:\ test \ test3.doc

'         C:\test\test3.doc

''C:\ test \ test4.doc

'         C:\test\test4.doc

'=============================================== ==============================

'=============================================================================

'常量

const forreading = 1

Const FORREADING =1

'变量声明

Dim objwordApp,objdocument,strInputFile,objFSO,strFileName,strPassword,objInputFile

Dim objwordApp,objdocument,strInputFile,objFSO,strFileName,strPassword,objInputFile

strInputFile = InputBox(输入输入文件的完整路径",输入文件的路径","I:\ files.txt",7500、7500)

strInputFile = InputBox("Enter the full path to the input file", "Path to Input File", "I:\files.txt", 7500, 7500)

strPassword = InputBox(输入将用于密码保护WORD文件的密码","Password","Password",7500、7500)

strPassword  = InputBox("Enter the password that will be used to password protect the WORD files", "Password", "Password", 7500, 7500)

设置objFSO = CreateObject("scripting.filesystemobject")

Set objFSO = CreateObject("scripting.filesystemobject")

设置objInputFile = objFSO.OpenTextFile(strInputFile,FORREADING)

set objInputFile = objFSO.OpenTextFile(strInputFile, FORREADING)

执行直到objInputFile.AtEndofStream

Do Until objInputFile.AtEndofStream

strFileName = objInputFile.ReadLine

     strFileName = objInputFile.ReadLine

设置objwordApp = CreateObject("word.Application")

     Set objwordApp = CreateObject("word.Application")

objwordApp.Visible =否

     objwordApp.Visible = FALSE

objwordApp.DisplayAlerts = FALSE

     objwordApp.DisplayAlerts = FALSE

设置objdocument = objwordApp.documents.Open(strFileName)

     Set objdocument = objwordApp.documents.Open(strFileName)

objdocument.activedocument.SaveAs strFileName,strPassword

     objdocument.activedocument.SaveAs strFileName,,strPassword

循环

objWORD.Quit

objWORD.Quit

设置objWordApp =无

Set objWordApp = nothing

设置objdocument =否

Set objdocument = nothing

wscript.echo完成"

wscript.echo "Done"

推荐答案

我不确定您的问题是什么,因为消息正文仅包含代码.没有迹象表明环境,Word版本,导致错误的确切行以及应该提供帮助的其他标准信息.

很明显,您是使用VSTO.有关什么是VSTO,VSTO论坛的目标以及有关非VSTO,Office相关问题的场所的链接的更多信息,请参考VSTO论坛的
I'm not sure what your question is, as the message body only contains code. There's no indication about the environment, the version of Word, the exact line causing the error, and other standard information that should accompany a request for assistance.

It is clear, however, that you are not using VSTO. For more information on what VSTO is, what the VSTO forum targets, and for links to venues for non-VSTO, Office-related question, I refer you to the VSTO forum's Please Read First message. I will move this message to the off-topic forum.

FWIW, glancing at your code, I'd say the problem comes from the construct: objdocument.activedocument

That just isn't something that exists in the Word object model. Try removing .activedocument


这篇关于键入不匹配,尝试在Word 2007中使用SaveAs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆