|
|
Question : Copy multiple pages in Word using VBA
|
|
Hello -
I would like to know if it is possible to copy pages in MS Word using VBA from one document to another. I would just like to be able to copy say for 3 and 56 from one document to another - is this possible ?
Thanks
GISVPN
|
Answer : Copy multiple pages in Word using VBA
|
|
Just do it twice
Private Sub CommandButton2_Click() Dim docNew As Word.Document Dim Path As String Dim rng As Range Dim p1 As Integer Dim p2 As Integer p1 = 2 p2 = 3 Set rng = ActiveDocument.Range Selection.GoTo wdGoToPage, wdGoToAbsolute, p1 rng.Start = Selection.Start Selection.GoTo wdGoToPage, wdGoToAbsolute, p1 + 2 rng.End = Selection.Start rng.Copy Set docNew = Application.Documents.Add docNew.Bookmarks("\EndOfDoc").Range.Paste p1 = 45 p2 = 45 Selection.GoTo wdGoToPage, wdGoToAbsolute, p1 rng.Start = Selection.Start Selection.GoTo wdGoToPage, wdGoToAbsolute, p1 + 2 rng.End = Selection.Start rng.Copy Set docNew = Application.Documents.Add docNew.Bookmarks("\EndOfDoc").Range.Paste
Path = Application.Options.DefaultFilePath(wdDocumentsPath) docNew.SaveAs Path & "\" & TextBox4.Text docNew.Close End Sub
What do you men by the 'Activedocument changes'
|
|
|
|
|