Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-17-2014, 08:37 AM
Baldeagle Baldeagle is offline Use of Macro SplitMergeForm Windows 8 Use of Macro SplitMergeForm Office 2013
Advanced Beginner
Use of Macro SplitMergeForm
 
Join Date: Apr 2012
Posts: 62
Baldeagle is on a distinguished road
Default Use of Macro SplitMergeForm

Last year I got considerable help in sending emails with 2 attachments. This year I have hit a snag. When I merge one of my attachments (see A) into a document with all the different individual forms in one document (see one such form in B) there is some distortion of the layout. But when I use the Macro SplitMergeForm it distorts the layout even more (see C which is the form to be attached to the emails).



Is there any way that the original layout can be maintained for the attachment?

My macro is as follows -
Code:
Sub SplitMergeForm()
'
' SplitMergeForm Macro
'
' splitter Macro modified to save individual Gift Aid (and Tax) Allocation Forms with

' information from data source. The filename data must be added to

' the top of the merge letter - see web article.

Dim sName As String
Dim docName As String
Dim Letters As String
Dim Counter As Long
Dim oDoc As Document
Dim oNewDoc As Document
Set oDoc = ActiveDocument
oDoc.Save

Selection.EndKey Unit:=wdStory
Letters = Selection.Information(wdActiveEndSectionNumber)
Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter < Letters
     Application.ScreenUpdating = False
     With Selection

          .HomeKey Unit:=wdStory
          .EndKey Unit:=wdLine, Extend:=wdExtend
          .MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend

     End With
     sName = Selection
     docName = "C:\Our Folders\BWMC\Form " & sName & ".doc"

     oDoc.Sections.First.Range.Cut
     Set oNewDoc = Documents.Add

    'Documents are based on the Normal template

    'To use an alternative template follow the link.
     With Selection
         .Paste
         .HomeKey Unit:=wdStory
         .MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
         .Delete
     End With
     oNewDoc.SaveAs FileName:=docName, _
        FileFormat:=wdFormatDocument, _
        AddToRecentFiles:=False
     ActiveWindow.Close
     Counter = Counter + 1
     Application.ScreenUpdating = True
Wend

oDoc.Close wdDoNotSaveChanges

End Sub
Attached Files
File Type: doc A.doc (55.5 KB, 11 views)
File Type: doc B.doc (54.5 KB, 10 views)
File Type: doc C.doc (55.5 KB, 9 views)
Reply With Quote
 

Tags
attachments, layout, merge



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Needed to bold specific lines and Macro to turn into CSV anewteacher Word VBA 1 05-28-2014 03:59 PM
custom icon, undo/redo for macro, permanent macro Rapier Excel 0 08-05-2013 06:30 AM
How do I assign a macro to a button when the macro is in my personal workbook? foolios Excel Programming 2 07-27-2011 02:41 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:29 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft