جمال جبريل قام بنشر يناير 9, 2017 قام بنشر يناير 9, 2017 وجدت هذا الكود في بعض المواقع الاجنبية وهي تنسخ اي شئ مكتوب في اي ورقة في اكسل الي مستند جديد في وورد Option Explicit Sub CopyWorksheetsToWord() ' requires a reference to the Word Object library:' --- Comment ' in the VBE select Tools, References and check the Microsoft Word X.X object library' --- Comment Dim wdApp As Word.Application, wdDoc As Word.Document, ws As Worksheet Application.ScreenUpdating = False Application.StatusBar = "Creating new document..." Set wdApp = New Word.Application Set wdDoc = wdApp.Documents.Add For Each ws In ActiveWorkbook.Worksheets Application.StatusBar = "Copying data from " & ws.Name & "..." ws.UsedRange.Copy ' or edit to the range you want to copy' --- Comment wdDoc.Paragraphs(wdDoc.Paragraphs.Count).Range.InsertParagraphAfter wdDoc.Paragraphs(wdDoc.Paragraphs.Count).Range.Paste Application.CutCopyMode = False wdDoc.Paragraphs(wdDoc.Paragraphs.Count).Range.InsertParagraphAfter ' insert page break after all worksheets except the last one' --- Comment If Not ws.Name = Worksheets(Worksheets.Count).Name Then With wdDoc.Paragraphs(wdDoc.Paragraphs.Count).Range .InsertParagraphBefore .Collapse Direction:=wdCollapseEnd .InsertBreak Type:=wdPageBreak End With End If Next ws Set ws = Nothing Application.StatusBar = "Cleaning up..." ' apply normal view' --- Comment With wdApp.ActiveWindow If .View.SplitSpecial = wdPaneNone Then .ActivePane.View.Type = wdNormalView Else .View.Type = wdNormalView End If End With Set wdDoc = Nothing wdApp.Visible = True Set wdApp = Nothing Application.StatusBar = False End Sub اريد فقط ان يتم تعديل الكود لينسخ كل الجداول الموجودة في اكسل الي ملف وورد بدلا من نسخ كل شئ مكتوب في اكسل
الردود الموصى بها
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.