mở word có mailings bằng code VBA
Chào các bạn GPE, mình có đoạn code sau để mở file word mailings và xuất file word mailings đó ra file pdf bằng VBA, nhưng khi áp dụng vào bài của mình thì bị lỗi không mở lên được
Mình không biết sửa thế nào,các bạn xem giúp và sửa giúp mình nhé, làm sao để mở file word mailngs sau đó xuất ra file pdf mailings bằng code VBA !, mình cảm ơn các bạn nhiều ạ !3238
32393240Private Sub CommandButton1_Click() Dim word_app As Object, doc As Object, link As Variant Set word_app = CreateObject("Word.Application") With word_app .Visible = True link = "E:stt.docx" Set doc = .documents.Open(link) End With doc.MailMerge.OpenDataSource Name:="E:Data.xlsm", SQLStatement:="SELECT * FROM `Word$`" End Sub
Bạn thử code này xem
Private Sub CommandButton1_Click()
Dim wordApp As Object
Dim doc As Object
Dim link As String
Set wordApp = CreateObject("Word.Application")
With wordApp
.Visible = True
link = "E:stt.docx"
Set doc = .Documents.Open(link)
End With
doc.MailMerge.MainDocumentType = wdFormLetters
doc.MailMerge.OpenDataSource Name:="E:Data.xlsm", _
LinkToSource:=True, _
Connection:="Data Source=E:Data.xlsm;Mode=Read", _
SQLStatement:="SELECT * FROM `Word$`"
doc.MailMerge.Execute
End Sub
www.giaiphapexcel.com/diendan/threads/m%E1%BB%9F-word-c%C3%B3-mailings-b%E1%BA%B1ng-code-vba.163982/
Khóa học SprinGO phù hợp
Khóa học Power PI – Ứng dung trong Nhân sự
TỔNG QUAN KHÓA HỌC: POWER BI CHO NGÀNH NHÂN SỰ Khóa học Power BI cho Nhân sự được thiết kế dành riêng cho các...
Xem khóa họcBạn nên đọc

Email Word with Message (Uses xlDialogSendMail & Outlook Express)

Chuyển code mã hóa tiếng Việt thành số thành code chạy trong Word?

Tặng Addin Word xuất Mail Merge có chức năng cắt ra nhiều file và gửi mail.

Add-In .xlam trộn dữ liệu Excel vào Word

Nhờ mọi người giúp mình cách file excel, word tự xóa theo từng thời điểm ạ.
![[Giúp đỡ] Tìm kiếm, lọc và lấy dữ liệu từ nhiều file Word vào 1 file excel](https://hrspring.vn/wp-content/uploads/logo-size-to-spr-320.webp)
Bình luận