Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-26-2021, 01:18 PM
asm1234 asm1234 is offline Split Multiple Word Documents by Bookmark Windows 10 Split Multiple Word Documents by Bookmark Office 2019
Novice
Split Multiple Word Documents by Bookmark
 
Join Date: Jul 2021
Posts: 3
asm1234 is on a distinguished road
Default Split Multiple Word Documents by Bookmark

Hello all,




I'm trying to split multiple Word documents into separate documents using the document bookmarks. I found a previously posted macro that works great for doing this. However, I'm running into an issue with the code as it relates to my project.



I'm trying to have the VBA loop across ~300 documents where all have the same bookmark names and are all in the same folder. It looks like the code loops across documents based on the "StrNm = Dir()" line. However, the newly saved folders are based on bookmark names, which are the same across all documents. It looks like this is causing an error and the marco to stop after the first document.



I want to adjust the code in two ways to (1) deal with the bookmark naming issue and (b) create new documents within the same folder (aka not create new folders for each new document. For example, the new documents should be roughly "[docname]_[bookmarkname].doc". How might I accomplish this?



Thanks in advance for any assistance someone can provide!
Reply With Quote
  #2  
Old 08-01-2021, 06:55 PM
Guessed's Avatar
Guessed Guessed is offline Split Multiple Word Documents by Bookmark Windows 10 Split Multiple Word Documents by Bookmark Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 2,554
Guessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to behold
Default

Can you post a few sample documents so we can test the code on what you actually have. The code you are using looks like it makes assumptions on where bookmarks start and end and deals with how many of the bookmarks overlap. Your documents might not follow the same patterns that it is coded for.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 08-02-2021, 10:47 AM
asm1234 asm1234 is offline Split Multiple Word Documents by Bookmark Windows 10 Split Multiple Word Documents by Bookmark Office 2019
Novice
Split Multiple Word Documents by Bookmark
 
Join Date: Jul 2021
Posts: 3
asm1234 is on a distinguished road
Default

Apologies, but I can't share any of the text files. However, the bookmarks are all in the proper place in each file. No overlap across bookmarks either. Where one ends, the next starts in all of the documents.

The problem is that the bookmarks have the same name in each file (not my doing). This keeps the script from working for more than one document at a time.
Reply With Quote
  #4  
Old 08-02-2021, 04:28 PM
Guessed's Avatar
Guessed Guessed is offline Split Multiple Word Documents by Bookmark Windows 10 Split Multiple Word Documents by Bookmark Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 2,554
Guessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to beholdGuessed is a splendid one to behold
Default

Are all your files .doc or something else such as .docx?

This code (as written) only returns .doc files
StrNm = Dir(StrPth & "\*.doc", vbNormal)
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #5  
Old 08-02-2021, 06:40 PM
asm1234 asm1234 is offline Split Multiple Word Documents by Bookmark Windows 10 Split Multiple Word Documents by Bookmark Office 2019
Novice
Split Multiple Word Documents by Bookmark
 
Join Date: Jul 2021
Posts: 3
asm1234 is on a distinguished road
Default

Yes, all files are in .doc format (I converted them with some other VBA code). Again, the ONLY issue I am dealing with is the bookmarks have the same names across files.


Here is what's happening: when I run the code, it creates folders with the files split based on the bookmarks in it for the *FIRST* document. Then, it gives me an error and cannot create folders with files in it it for the second document because said folders/files already exist. As mentioned, all the bookmarks have the same name and that's what used to name the folders/files.


I suspect all I need is an additional line of code to adjust the name of the folders/files. For example, it would work if the saved files end up being "[originalfilename]_[bookmarkname].doc" rather than what it is right now, "[bookmarkname].doc". That would solve the issue. However, I couldn't get anything like that to work with my code, so I'm reaching out on here.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Split Multiple Word Documents by Bookmark VBA to split Word document into multiple documents Shelley Lou Word VBA 1 02-24-2021 07:11 AM
Split Multiple Word Documents by Bookmark split word document based on bookmarks with each new document title of the bookmark megatronixs Word VBA 9 09-05-2020 02:29 PM
Split Multiple Word Documents by Bookmark Macro to Split Documents Gingerbreadgrl Word VBA 4 09-02-2019 03:18 PM
Split Multiple Word Documents by Bookmark Mail Merge - split merged documents and rename each split document based on text in header FuriousD Word VBA 1 05-12-2019 04:06 AM
Split one Word Document into Multiple PDFs VieraOfficeUser Word 3 07-30-2014 10:58 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:32 AM.


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