Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7511583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:35:38+00:00 2026-05-29T23:35:38+00:00

I did a mailmerge to create dynamic word pages with customer information. Then I

  • 0

I did a mailmerge to create dynamic word pages with customer information.

Then I did (by looking on the net) a macro to split the result file into several pages, each page being saved as one file.

Now I’m looking to give those files some names containing customer info. I googled that and I think the (only?) way is to create a mergefield with that info, at the very beginning of the page, then extract and delete it from the page with a macro to put it in file names.

Example: If I have a customer named Stackoverflow I would like to have a file named Facture_Stackoverflow.doc.

I found nowhere how to select, extract and then delete this first word from my page.

Here is my “splitting macro”, which currently names the files just with an incremented ID:

Sub DecouperDocument()
    Application.Browser.Target = wdBrowsePage

    For i = 1 To ActiveDocument.BuiltInDocumentProperties("Number of Pages")

        ActiveDocument.Bookmarks("\page").Range.Copy

        Documents.Add
        Selection.Paste

        Selection.TypeBackspace
        ChangeFileOpenDirectory "C:\test\"
        DocNum = DocNum + 1
        ActiveDocument.SaveAs FileName:="Facture_" & DocNum & ".doc"
        ActiveDocument.Close

        Application.Browser.Next
    Next i
    ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T23:35:42+00:00Added an answer on May 29, 2026 at 11:35 pm

    The function below will enable you to extract the first word (and optionally remove it) of a Word document.

    Public Function GetFirstWord(Optional blnRemove As Boolean = True) As String
    
        Dim rng As Range
        Dim intCharCount As Integer
        Dim strWord As String
    
        With ThisDocument
            Set rng = .Characters(1)
    
            intCharCount = rng.EndOf(wdWord, wdMove)
    
            With .Range(0, intCharCount - 1)
                strWord = .Text
                If blnRemove Then
                    .Delete
                End If
            End With
        End With
    
        GetFirstWord = strWord
    
    End Function
    

    I hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Did you used Dynamic websites before? you see its a good way for making
Did some searches here & on the 'net and haven't found a good answer
Did you ever have the following situation: you need to store information, but a
Did not have luck with these examples: Javascript File remove Javascript FSO DeleteFile Method
Did anyone try to read programmatically an Alibre Design CAD file? I see that
Did anybody know more information about this attack ? I recently got this script
Did my research on this, couldn't find what I was looking for. Tried ReflectionClass
Did a new install of postgres 8.4 on mint ubuntu. How do I create
What's the best way to create printable letters from an MVC application? I'm looking
Did anyone already wrote code for converting doc or docx to pdf using Word

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.