|
-
Jan 31st, 2006, 06:31 AM
#1
Thread Starter
New Member
[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:
Sub SplitLetters()
Dim mask As String
Selection.EndKey Unit:=wdStory
Letters = Selection.Information(wdActiveEndSectionNumber)
mask = "<<Company>>"
Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter < Letters
DocName = "D:\Merged\" & Format(Date, mask) _
& " " & LTrim$(Str$(Counter)) & ".doc"
ActiveDocument.Sections.First.Range.Cut
Documents.Add
With Selection
.Paste
.EndKey Unit:=wdStory
.MoveLeft Unit:=wdCharacter, Count:=1
.Delete Unit:=wdCharacter, Count:=1
End With
ActiveDocument.SaveAs FileName:=DocName, FileFormat:=wdFormatDocument
ActiveWindow.Close
Counter = Counter + 1
Wend
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|