Results 1 to 4 of 4

Thread: [RESOLVED] Specific VB Coding Explanation?

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    2

    Resolved [RESOLVED] Specific VB Coding Explanation?

    Hi,

    I'm new here, so sorry if this is in the wrong place (I couldn't find anywhere else relevant). For a project I'm currently working on, I need to explain the coding I have used in Word. I'd found a code online, and tried to edit it to suit my requirements - I'm in no way an expert so it could be full of errors, but does what I wish. The macro I've been using splits a mail merged document into separate documents.

    I need the code explained line-by-line, so basically what each line does/means. If anybody could provide me with any help, I'd be incredibly grateful as I'm very new to VB.

    Thanks in advance,
    Marie.
    VB Code:
    1. Sub SplitLetters()
    2.  
    3. Dim mask As String
    4. Selection.EndKey Unit:=wdStory
    5. Letters = Selection.Information(wdActiveEndSectionNumber)
    6. mask = "<<Company>>"
    7.  
    8. Selection.HomeKey Unit:=wdStory
    9. Counter = 1
    10. While Counter < Letters
    11. DocName = "D:\Merged\" & Format(Date, mask) _
    12. & " " & LTrim$(Str$(Counter)) & ".doc"
    13. ActiveDocument.Sections.First.Range.Cut
    14. Documents.Add
    15. With Selection
    16.   .Paste
    17.   .EndKey Unit:=wdStory
    18.   .MoveLeft Unit:=wdCharacter, Count:=1
    19.   .Delete Unit:=wdCharacter, Count:=1
    20. End With
    21.  
    22. ActiveDocument.SaveAs FileName:=DocName, FileFormat:=wdFormatDocument
    23. ActiveWindow.Close
    24. Counter = Counter + 1
    25. Wend
    26.  
    27. End Sub
    Last edited by Marie_; Jan 31st, 2006 at 06:38 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width