本帖最后由 PPTBS 于 2015-1-12 12:17 编辑 Private Sub Command1_click()
Dim oApp As Word.Application
Dim oDoc As Word.Document
Dim oMerge As Word.MailMerge
Dim oResult As Word.Document
Set oApp = CreateObject("Word.Application")
'Open a Word MailMerge document
Set oDoc = oApp.Documents.Add("C:\bak\1.doc", False, wdNewBlankDocument, False)
'Instanciate a MailMerge object
Set oMerge = oDoc.MailMerge
With oMerge
'Set the source where your data will be coming from
.OpenDataSource "C:\bak\2.xls"
'Specify the output destination. ie: a new document or a printer etc
.Destination = wdSendToNewDocument 'OR wdSendToPrinter if you just want to print
.Execute
End With
'Do stuff with the document if you want via the oResult document object
Set oResult = oApp.ActiveDocument 'This is your merged document (if shown).
oApp.Visible = True
ChangeFileOpenDirectory "C:\Documents and Settings\Administrator\桌面"
ActiveDocument.SaveAs FileName:="1.doc", FileFormat:=wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:=False
oResult.Close SaveChanges:=False
Set oResult = Nothing
Set oMerge = Nothing
oDoc.Close SaveChanges:=False
Set oDoc = Nothing
oApp.Quit SaveChanges:=False
Set oApp = Nothing
VB的代码 转换成AU3代码怎么都转换失败
问题出在 wdNewBlankDocument 上面 wdNewBlankDocument 是常量 我用AU3 老是显示没有命名,转化成字符串格式又不对,给一点思路! |