標題:
[發問]
如何在Excel Vba之下套用上列Word Vba?
[打印本頁]
作者:
yangjie
時間:
2014-1-19 00:55
標題:
如何在Excel Vba之下套用上列Word Vba?
請教各位先進大大:
以下是我在Word中錄製加以修正 可以在Word中正常Run
ChangeFileOpenDirectory ActiveDocument.Path & "\"
Documents.Open FileName:="A4-3X7.doc", ConfirmConversions:=False
Windows("A4-3X7.doc").Activate
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
ChangeFileOpenDirectory ActiveDocument.Path & "\"
ActiveDocument.SaveAs FileName:="套表.doc", FileFormat:=wdFormatDocument, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
如何送出給列表機?語法?
ActiveWindow.Close
以上程序 應如在Excel Vba下語法 執行
1.在Excel 下開:"A4-3X7.doc"
2.在Excel Vba之下套用上列Word Vba
懇求協助
謝謝
作者:
GBKEE
時間:
2014-1-20 08:01
本帖最後由 GBKEE 於 2014-1-20 08:03 編輯
回復
1#
yangjie
試試看
Excel的VBA
Option Explicit
Public appWD As Object
Sub Ex()
Set appWD = CreateObject("Word.Application")
With appWD
.Visible = True
.ChangeFileOpenDirectory "D:\"
.Documents.Open Filename:="Doc1.doc"
.Run "Doc1!ThisDocument.ex1" '執行這巨集
'如ThisDocument 中有 Sub Document_Open() 亦會自動執行
'.Quit '關閉Word
End With
'Set appWD = Nothing
End Sub
複製代碼
作者:
yangjie
時間:
2014-1-20 10:45
回復
2#
GBKEE
萬分感激
完全解決
謝謝
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)