Lewati ke konten utama

Menggabungkan Dokumen Word di Power Automate

Apa yang dilakukan oleh tindakan ini?

PDF4meGabungkan Dokumen menggabungkan beberapa file Word (DOCX/DOC) menjadi satu dokumen gabungan di dalam Power Automate Alurnya. Kendalikan Urutan penggabungan dengan SortPosition, pilih bagaimana gaya ditangani (KeepSourceFormatting, UseDestinationStyles, KeepDifferentStyles), dan menetapkan OOXML tingkat kepatuhan. Ambil dokumen dari SharePoint, OneDriveBaik melalui Dropbox, atau email, hasilnya berupa satu file yang bersih dan tunggal. DOCX siap untuk didistribusikan atau diproses lebih lanjut.

Postingan Blog Terkait
Belum ada postingan blog untuk fitur ini — akan segera hadir.
Sementara itu, jelajahi blog PDF4me untuk menemukan tutorial dan alur kerja di berbagai platform.
Kunjungi blog ini

Memverifikasi Identitas Anda API Meminta

Setiap PDF4me tindakan dalam Power Automate memerlukan validitas koneksiMasukkan milik Anda PDF4me API Kuncinya adalah, saat Anda menambahkan aksi untuk pertama kalinya, aksi tersebut akan digunakan kembali secara otomatis di semua aksi berikutnya. PDF4me tindakan dalam alur yang sama.

Fakta Penting yang Tidak Boleh Anda Lewatkan

SortPosition mengontrol urutan penggabungan
Setiap dokumen dalam array membutuhkan sebuah SortPosition nilai. Dokumen digabungkan dalam urutan menaik, posisi 0 menjadi dokumen dasar. Anda dapat menggunakan skema penomoran apa pun (0, 1, 2 atau 10, 20, 30). Saat mengambil file dari loop, tetapkan secara dinamis SortPosition dengan menggunakan indeks iterasi sehingga urutan selalu deterministik terlepas dari bagaimana file diambil dari penyimpanan.
FormatMode menentukan bagaimana gaya-gaya tersebut diselaraskan
KeepSourceFormatting (default) mempertahankan gaya masing-masing dokumen. UseDestinationStyles Menerapkan gaya dokumen pertama ke semua konten yang digabungkan, paling cocok jika Anda menginginkan tampilan yang seragam. KeepDifferentStyles Mempertahankan gaya yang berbeda dan hanya menggabungkan gaya yang identik. Untuk laporan bermerek dengan templat tetap, gunakan UseDestinationStyles dengan templat sebagai posisi 0.
DocContent harus berupa file biner, bukan URL atau jalan
Yang DocContent Kolom untuk setiap dokumen mengharapkan konten biner mentah dari file Word, bukan SharePoint URL atau jalur file. Gunakan Power Automate Pertama-tama, lakukan tindakan Dapatkan Konten File pada setiap dokumen, lalu petakan isi keluarannya ke DocContent. Untuk SharePoint, Mendapatkan Konten File Menggunakan Jalur akan mengembalikan data biner secara langsung, tanpa perlu langkah pengkodean tambahan.
Tindakan Power Automate PDF4me Merge Documents menampilkan larik Documents dengan dua entri: masing-masing berisi Filename, DocContent yang dipetakan dari langkah SharePoint Get File Content, SortPosition 0 dan 1, dan FormatMode UseDestinationStyles: ditambah Merge Options Compliance Level yang diatur ke Transitional.

Buat array Dokumen dengan satu entri per file. Petakan DocContent dari langkah Dapatkan Konten File, bukan URL. SortPosition 0 adalah dokumen dasar; semua dokumen lainnya ditambahkan secara berurutan.

Parameter

Diperlukan: Array dokumen dengan setidaknya satu entri. Setiap entri membutuhkan Nama berkas, DocContent (file biner), dan SortPosition. FormatMode dan Opsi Penggabungan bersifat opsional.

ParameterDiperlukanApa fungsinya?Contoh
DocumentsYesArray of document objects to merge. Each object requires Filename, DocContent, and SortPosition. The array must contain at least one entry. Documents merge in ascending SortPosition order.[{Filename, DocContent, SortPosition}]
Documents[].FilenameYesFilename of the document including extension. Must be .docx or .doc. Used for format detection and document identification during merge.chapter1.docx
Documents[].DocContentYesRaw binary content of the Word file. Map from the output body of a SharePoint Get File Content or OneDrive Get File Content action. Do not pass a URL, path, or filename string here.File Content body
Documents[].SortPositionYesInteger determining merge order. The document with the lowest SortPosition becomes the base document. All others are appended in ascending order. Use any integers: 0, 1, 2 or 10, 20, 30 are both valid.0
Documents[].FormatModeNoHow styles are handled for this document during merge. Options: KeepSourceFormatting (default: preserves document's own styles), UseDestinationStyles (adopts base document styles), KeepDifferentStyles (retains distinct styles only).UseDestinationStyles
Merge Options Time ZoneNoTimezone identifier added to the merged document metadata. Use standard identifiers like UTC, Asia/Kolkata, or America/New_York. Default: none.UTC
Merge Options Compliance LevelNoOOXML compliance standard for the output document. Options: ECMA (ECMA-376 2006), Transitional (ISO 29500 Transitional, default and recommended), Strict (ISO 29500 Strict). Use Transitional for broadest Microsoft 365 compatibility.Transitional

Bidang Keluaran

BidangJenisIsi di dalamnya
documentBinaryThe merged Word document as a binary. Map into SharePoint Create File, Send Email attachment, or a Convert Word to PDF action.
SuccessBooleantrue if the merge completed without errors. Use in a Condition step to branch on failure and send an error notification.
Error MessageStringHuman-readable error description if Success is false. Null when successful. Include in failure notification emails.
ErrorsArrayArray of detailed error objects when Success is false. Each entry has Code and Message fields for debugging.

Pesan Kesalahan Umum

Pesan KesalahanMenyebabkanMemperbaiki
No documents to mergeDocuments array is null or emptyPass at least one document object in the Documents array with Filename, DocContent, and SortPosition.
Error loading document from bytesInvalid or corrupted Word file in DocContentVerify DocContent comes from a Get File Content action returning a valid .docx binary: not a URL or path.
Unknown FormatMode, defaulting to KeepSourceFormattingInvalid FormatMode valueUse only: KeepSourceFormatting, KeepDifferentStyles, or UseDestinationStyles.
Error merging documentsGeneral exception during mergeCheck that all documents are valid Word files (.docx). Review the Errors array for details.

Pengaturan Cepat

  1. Di dalam dirimu Power Automate mengalir, klik + Tambahkan tindakan dan mencari PDF4me Kata.
  2. Pilih Gabungkan Dokumen.
  3. Masukkan nama Anda PDF4me API Masukkan kode di dialog koneksi (atau pilih koneksi yang sudah ada).
  4. Untuk setiap dokumen yang akan digabungkan, tambahkan SharePoint Dapatkan Konten File atau OneDrive Dapatkan Konten File tindakan di atas langkah ini.
  5. Di dalam Dokumen array, tambahkan satu entri per file. Atur Nama berkas (dengan .docx), DocContent (biner dari langkah Dapatkan Konten File), dan SortPosition (0 untuk basis, 1, 2... untuk file selanjutnya).
  6. Mengatur FormatMode: menggunakan UseDestinationStyles jika dokumen dasar (posisi 0) adalah templat bermerek Anda.
  7. Mengatur Tingkat Kepatuhan Opsi Penggabungan ke Transitional untuk kompatibilitas seluas-luasnya.
  8. Kabel dokumen keluaran ke dalam SharePoint Buat File atau Kirim Email aksi. Tambahkan Kondisi pada Kesuksesan untuk menangani kegagalan dengan pemberitahuan kesalahan.

Contoh Alur Kerja

Contoh Alur KerjaCommon Power Automate flow patterns using Merge Documents.
Bagian laporan disetujui → gabungkan sesuai urutan → kirim laporan yang telah disusun melalui email
  1. A SharePoint Perubahan item memicu alur kerja ketika semua bagian laporan ditandai "Disetujui" di kolom status.
  2. Empat langkah Get File Content mengambil halaman sampul (posisi 0), ringkasan eksekutif (1), isi utama (2), dan lampiran (3) dari pustaka Laporan.
  3. Gabungkan Dokumen menggabungkan keempatnya dalam SortPosition pesan dengan FormatMode diatur ke UseDestinationStyles, gaya templat halaman sampul diterapkan secara seragam di seluruh halaman.
  4. Kondisi Berhasil akan mengarahkan kegagalan ke notifikasi Teams untuk pemilik laporan.
  5. Kirim Email melampirkan hasil penggabungan DOCX Laporkan ke daftar distribusi manajemen. SharePoint Buat File akan mengarsipkannya di pustaka Laporan yang Diterbitkan.
Bagian-bagian kontrak diselesaikan → digabungkan → dikonversi ke PDF → diproses untuk eksekusi
  1. Pemicu persetujuan aktif Power Automate ketika tahap peninjauan hukum selesai dalam alur kerja persetujuan kontrak.
  2. Langkah-langkah Mendapatkan Konten File mengambil header kontrak (0), Syarat & Ketentuan (1), klausul spesifik (2), dan halaman tanda tangan (3) dari perpustakaan Hukum.
  3. Gabungkan Dokumen menyusun kontrak secara lengkap. FormatMode adalah KeepSourceFormatting dan Tingkat Kepatuhan sangat Ketat untuk standar dokumen hukum.
  4. A PDF4me Tindakan Konversi Word ke PDF menghasilkan PDF siap cetak dari kontrak yang telah digabungkan.
  5. Fitur Kirim Email mengirimkan kontrak akhir yang telah diberi nomor kepada pihak-pihak terkait. SharePoint arsip keduanya DOCX Dan PDF di dalam folder Kontrak yang Telah Dieksekusi.
Jumlah bagian proposal yang bervariasi → perulangan → kumpulkan → gabungkan → kirim ke klien
  1. Pemicu manual akan aktif ketika sebuah proposal sudah siap. SharePoint Get Files mengambil semua DOCX bagian-bagian dari folder Bagian Proposal untuk kesepakatan tersebut.
  2. Sebuah loop "Apply to Each" mengulangi daftar file. Setiap iterasi menjalankan "Get File Content" dan menambahkan objek dokumen (Filename, binary, iteration index as SortPosition) ke variabel array.
  3. Setelah perulangan, Gabungkan Dokumen menerima seluruh array. FormatMode adalah UseDestinationStyles, file pertama dalam folder (posisi 0) selalu berupa templat sampul bermerek.
  4. Penggabungan DOCX unggahan ke Hasil Kerja Klien SharePoint library. Send an Email mengirimkannya ke kontak klien dengan pesan pengantar yang dipersonalisasi.

Pertanyaan yang Sering Diajukan

What is SortPosition and how do I control the merge order?+
SortPosition is an integer assigned to each document in the Documents array. The action merges documents in ascending order: position 0 becomes the base document and all others are appended in order. You can use any integers: 0, 1, 2 or 10, 20, 30 are equally valid. When processing files from an Apply to Each loop in Power Automate, use the loop iteration index as SortPosition to ensure a deterministic merge order regardless of how SharePoint returns the files.
Which FormatMode should I use for branded company documents?+
Use UseDestinationStyles when the document at SortPosition 0 is your branded template: all merged content from other documents adopts the template's styles for a uniform look throughout the assembled document. Use KeepSourceFormatting (the default) when each document should retain its own styles, appropriate for merging independently authored sections where style variety is acceptable. Use KeepDifferentStyles when you want to preserve distinct styles from different contributors while merging identical style definitions.
Why does DocContent need to be the file binary and not a URL or SharePoint path?+
The DocContent field expects the raw binary bytes that make up the DOCX file. Use a SharePoint Get File Content or OneDrive Get File Content action before this step and map its Body (or File Content) output into DocContent. Passing a URL, a SharePoint path string, or a filename causes an invalid document error because the action cannot download or resolve file references: it can only process binary content it receives directly.
How do I merge a variable number of files: for example, all DOCX files in a SharePoint folder?+
Use an Apply to Each loop. Add a SharePoint Get Files action to list all DOCX files in the folder. Inside the loop, add Get File Content and append a document object (Filename, binary Content, and current item index as SortPosition) to an array variable initialized before the loop. After the loop exits, pass the completed array variable to the Merge Documents action. This pattern handles any number of files: from 2 to 200, without changing the flow structure.
What does the action return and how do I handle merge failures gracefully?+
The action returns document (merged DOCX binary), Success (boolean), Error Message (string), and Errors (array). After the action, add a Condition step that checks if Success equals true. On the false branch, use Send an Email or Post a Message (Teams) to notify the flow owner with the Error Message value so failures are visible without having to check run history manually. On the true branch, proceed with the Create File and email distribution steps.

Tindakan Terkait

Dapatkan Bantuan