Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Access / Word VBA Gurus
Chris Bezant 
      
11 months ago
I am a volunteer for a charity here in UK that supports the visually impaired of Hampshire.
Naturally, I have created a database to manage my clients.
This works well but parts of the process are tedious.
Client details arrive in a Word document which I use to extract certain information for my database.
When the client work is finished, I have to complete the details in a Word document.
What I would like to do is write some code to extract details from a Word document to avoid my cut/paste process.
The document is a standard format and has lines like Allocated To followed by Chris Bezant.
I need to search for Allocated To and extract the text that follows i.e. Chris Bezant.
Then I would like to write my feedback to a Word document.
Again, this is a fixed format, so I need to search for Service Provided and insert text after that.
In the past I have done a lot of Access/Excel coding but for Word I am stumped.
Can any of you VBA Gurus help me, please?



Donald Blackwell  @Reply  
       
11 months ago
Watching with interest...

I have a few related tasks on my "to-do-list". I've been reviewing Access Developer 39 and Export to Word but any time I can soak up additional insights from others' posts is a treat.
Alex Hedley  @Reply  
           
11 months ago
Have you tried anything with the macro recorder first, outside of Access just to see what's possible?

Have you tried creating a Word object in Access VBA and opening an existing file?
Kevin Yip  @Reply  
     
11 months ago
The layout of the Word document will dictate what strategy to use.  Is it in a columnar format, with labels in one column and fields in another, with both columns neatly placed next to one another?  Or are the labels and fields placed in random locations?  Are tables used in the Word doc?  If everything is placed randomly, but a field value is always preceded with its label (name always preceded by "Allocated to", like you said), that you can add a new line right before every label, which can be done with the VBA function Replace().  E.g. s = Replace(s, "Allocated to", vbCrLf & "Allocated to")

Then, randomly placed text like this:

Name:  John Doe    Age:  M    Address:  100 Any Town, CT 98765   Married: Y
Employer:  Any Company, Ltd.   Employee Address: 200 Any Town, CT 98765  

will become this:

Name:  John Doe
Age:  M
Address:  100 Any Town, CT 98765
Married: Y
Employer:  Any Company, Ltd.
Employee Address: 200 Any Town, CT 98765

Then it will become much easier to extract info from it.  You may even be able to import this directly to an Access table, then read each line of the table and extract the info.
Garry Smith  @Reply  
    
10 months ago
Watching with interest...
Richard Rost  @Reply  
          
10 months ago
To ChatGPT: take the text from this document and extract the following fields...

LOL

Kevin has the right strategy. Layout the text of the Word document in as "data friendly" of a format as possible. This will help you import it. You can then read it in line by line and check the first X characters of each line for things like "First Name:" or "Address:" and put them in the appropriate fields.

Save the Word document as text, and then at that point it just becomes basic file I/O.
Chris Bezant OP  @Reply  
      
10 months ago
Thanks for your ideas, guys. I will have a play and see what I come up with.
Just to be clear, the document arrives in a fixed format where items are on separate lines of a label followed by data. This is not a Word table.
My responses must be returned in the same layout.
For supplying the response, I was hoping to issue Word instructions to locate a label, move the text cursor after the label then insert text.
Anyway, thank you all for taking the time to help me with this.
I will report back with my solution when I have cracked it.
Richard Rost  @Reply  
          
10 months ago
Yeah, it's basically save it as a text file and then if you could figure out what the structure is, you're going to read it in line-by-line and just look at the beginning of each line for the field name.

If Len(S,5) = "Name:" then NameField=Trim(Right(S,Len(S)-5))

Loop thru all the lines, and you've got it.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 8/7/2026 10:05:00 PM. PLT: 0s