|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
在做工资里
可使用WORD来打印工资条
但数据是存放在EXCEL中的
同时EXCEL设置了打开密码的
请问在VBA中应如何设置?谢谢~~
我的代码如下(录制的,含自动另存):
'
' a Macro
'
'
ActiveDocument.MailMerge.MainDocumentType = wdCatalog
ActiveDocument.MailMerge.OpenDataSource Name:= _
ActiveDocument.Path & "\工资表.xls", ConfirmConversions:=False, _
ReadOnly:=False, LinkToSource:=True, AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False, Format:=wdOpenFormatAuto, _
Connection:="整张电子表格", SQLStatement:="", SQLStatement1:="", SubType:= _
wdMergeSubTypeOther
ActiveDocument.MailMerge.Execute Pause:=False
Application.DisplayStatusBar = True
Application.ShowWindowsInTaskbar = True
Application.ShowStartupDialog = True
With ActiveWindow
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayLeftScrollBar = False
.StyleAreaWidth = CentimetersToPoints(0)
.DisplayVerticalRuler = True
.DisplayRightRuler = False
.DisplayScreenTips = True
With .View
.ShowAnimation = True
.Draft = False
.WrapToWindow = False
.ShowPicturePlaceHolders = False
.ShowFieldCodes = False
.ShowBookmarks = False
.FieldShading = wdFieldShadingWhenSelected
.ShowTabs = False
.ShowSpaces = False
.ShowParagraphs = True
.ShowHyphens = False
.ShowHiddenText = False
.ShowAll = False
.ShowDrawings = True
.ShowObjectAnchors = False
.ShowTextBoundaries = False
.ShowHighlight = True
.ShowOptionalBreaks = False
.DisplayPageBoundaries = True
.DisplaySmartTags = True
End With
End With
With ActiveDocument
.ReadOnlyRecommended = False
.Password = "000000"
.WritePassword = ""
.RemovePersonalInformation = False
.RemoveDateAndTime = False
End With
With Options
.WarnBeforeSavingPrintingSendingMarkup = False
.StoreRSIDOnSave = True
.ShowMarkupOpenSave = True
End With
ActiveDocument.SaveAs FileName:="本月份工资条.doc", FileFormat:=wdFormatDocument _
, LockComments:=False, Password:="000000", AddToRecentFiles:=True, _
WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
End Sub
使用这个代码为什么会出现数据连接属性?
点确定后,会出现“ODBC驱动程序登陆失败 不能解密文件”
此时只能点取消,然后再输入EXCEL的密码才能正常使用!
请版主帮忙解决一下这个问题
实在不好意思
[此贴子已经被作者于2006-3-22 10:46:38编辑过] |
|