Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-14-2018, 08:45 PM
kateabode kateabode is offline Help with Inserting External Information into Document Consecutively Windows 7 64bit Help with Inserting External Information into Document Consecutively Office 2016
Novice
Help with Inserting External Information into Document Consecutively
 
Join Date: Sep 2018
Posts: 16
kateabode is on a distinguished road
Default Help with Inserting External Information into Document Consecutively

I'm not entirely sure how to describe what I'm trying to do, but I'll give it a go.

I have a userform with checkboxes. If Checkbox 1 is selected, it copies information from external doc using bookmarks to a bookmark in the activedocument.

With this though, I realised that I couldn't add 100+ bookmarks to the one line so I have had to create a new paragraph on the empty sheet for each bookmark.

It all works very well, however, if for example I don't select Checkboxes 10-20 then there is a big gap in the document where the paragraphs that contain the bookmarks are still there.

I was thinking I might need some code to delete the bookmark if not selected? I have searched and tried my hardest to do this but nothing works.



An alternative I was thinking might be to use paragraphs instead of bookmarks in the activedocument but then I'm not sure how to code to tell it to go to the next paragraph, as I can't just say checkbox 1=paragraph 35 checkbox2=paragraph 36 because what if I decided not to select checkbox 1?

I hope this makes sense

I have attached the document to help with understanding what I mean
Attached Files
File Type: docm Form.docm (114.2 KB, 9 views)
Reply With Quote
  #2  
Old 10-14-2018, 11:43 PM
Guessed's Avatar
Guessed Guessed is offline Help with Inserting External Information into Document Consecutively Windows 10 Help with Inserting External Information into Document Consecutively Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,967
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

You have a few choices.
1. Have a single bookmark in the target document and keep adding content to the end of that range.
2. Include a paragraph mark in each bookmark of the source document so they bring in their own paragraphs.
3. Run a step that hides the paragraphs with an empty bookmark.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 10-15-2018, 01:35 AM
gmayor's Avatar
gmayor gmayor is offline Help with Inserting External Information into Document Consecutively Windows 10 Help with Inserting External Information into Document Consecutively Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

If the texts are consecutive, then why bother with the bookmarks at all. Just add them one after another as required. See attached. Create a new document from the template. See also the button on the QAT (Quick Access Toolbar)

As I don't have your source document, I could not test the code, but it should be much closer to what you need and works with a test source, provided the bookmarked texts include the final paragraph marks..
Attached Files
File Type: dotm Form.dotm (127.4 KB, 12 views)
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com

Last edited by gmayor; 10-15-2018 at 04:09 AM.
Reply With Quote
  #4  
Old 10-15-2018, 04:08 PM
kateabode kateabode is offline Help with Inserting External Information into Document Consecutively Windows 7 64bit Help with Inserting External Information into Document Consecutively Office 2016
Novice
Help with Inserting External Information into Document Consecutively
 
Join Date: Sep 2018
Posts: 16
kateabode is on a distinguished road
Smile

Quote:
Originally Posted by gmayor View Post
If the texts are consecutive, then why bother with the bookmarks at all. Just add them one after another as required. See attached. Create a new document from the template. See also the button on the QAT (Quick Access Toolbar)

As I don't have your source document, I could not test the code, but it should be much closer to what you need and works with a test source, provided the bookmarked texts include the final paragraph marks..
Graham (not Greg!) thank you so much. I don't know what you've done (it's all way beyond me abilities) but it's almost there now. My only concern is that if someone clicks on the toolbar button to edit it after the fact, it replaces everything that was there originally.

For example, we create the document using the userforms etc. Then make all our necessary typing entries into the document. Then in a couple of weeks we find out that we need to add in a section, let's say a swimming pool, if we click on the toolbar button to add it in, then we lose all of the typing that we have done initially. Is there a way around this?
Reply With Quote
  #5  
Old 10-15-2018, 08:12 PM
gmayor's Avatar
gmayor gmayor is offline Help with Inserting External Information into Document Consecutively Windows 10 Help with Inserting External Information into Document Consecutively Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

I simply made some minor changes to your code so that it would eliminate all those bookmarked paragraphs and moved it to the calling macro.

The only bookmarks in the created document are those of the inserted texts. Instead of writing to bookmarks the texts are written consecutively.

The template creates new forms, and are filled with the bookmarked sections. When you click the edit button the form is re-opened with the previous selections checked by reference to the bookmark names. The content is then cleared so that any changes made to the userform are reflected in the edited document. You shouldn't lose anything as it is all re-entered according to what is checked when you click the OK button.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #6  
Old 10-15-2018, 08:37 PM
kateabode kateabode is offline Help with Inserting External Information into Document Consecutively Windows 7 64bit Help with Inserting External Information into Document Consecutively Office 2016
Novice
Help with Inserting External Information into Document Consecutively
 
Join Date: Sep 2018
Posts: 16
kateabode is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
I simply made some minor changes to your code so that it would eliminate all those bookmarked paragraphs and moved it to the calling macro.

The only bookmarks in the created document are those of the inserted texts. Instead of writing to bookmarks the texts are written consecutively.

The template creates new forms, and are filled with the bookmarked sections. When you click the edit button the form is re-opened with the previous selections checked by reference to the bookmark names. The content is then cleared so that any changes made to the userform are reflected in the edited document. You shouldn't lose anything as it is all re-entered according to what is checked when you click the OK button.
Thanks for that. We make changes to the document by typing into the activedocument once the userform has populated it. So those changes will be lost if we then reopen the userform and add additional sections in, because it repopulates the whole document, thus deleting all typed entries into the document.

Is there a way to overcome this?
Reply With Quote
  #7  
Old 10-16-2018, 04:54 AM
gmayor's Avatar
gmayor gmayor is offline Help with Inserting External Information into Document Consecutively Windows 10 Help with Inserting External Information into Document Consecutively Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

If you are going to edit the inserted texts after they have been inserted and then use the process (or any process for that matter) to add or remove the inserted texts, you are creating a whole new bag of worms and it becomes a major programming exercise which is way beyond the assistance I am willing to provide via this forum.

Without knowing what is in the texts and what you are likely to want to change it is impossible to advise how to handle it.

If the texts contain editable sections using uniquely named content controls, then it should be possible to record not only the bookmarks inserted, but the values of those content controls, and re-apply the stored values to the named controls when the document is rebuilt. Otherwise you are going to have to compare what you had with what you want and work out a way to insert any additional texts in the correct places.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #8  
Old 10-16-2018, 04:57 PM
Guessed's Avatar
Guessed Guessed is offline Help with Inserting External Information into Document Consecutively Windows 10 Help with Inserting External Information into Document Consecutively Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,967
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

The method 3 I suggested whereby each bookmark's range can be hidden is the only one that works with your described requirements. Have you tried that yet?

The bookmarks cannot be completely emptied (because the order will become confused) but they could contain only a paragraph mark which can be hidden.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #9  
Old 10-17-2018, 02:31 AM
gmayor's Avatar
gmayor gmayor is offline Help with Inserting External Information into Document Consecutively Windows 10 Help with Inserting External Information into Document Consecutively Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

This problem got the better of my curiosity and on simplifying the code to avoid all those interminable sections relating to check boxes and bookmarks, it seems that recording the data from content controls in the bookmarked sections (provided the content controls are uniquely named) is fairly simple using a collection to hold the names and values.

Thus you can recall the userform to add a section and retain the inserted content control values. It won't of course restore ad hoc text. If you want to edit the bookmarked texts you'll need to add the content controls to hold the edits to the data document.

There are tools available from my web site to insert content controls easily and to ensure they are uniquely named.
Attached Files
File Type: dotm Form V3.dotm (121.9 KB, 10 views)
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com

Last edited by gmayor; 10-17-2018 at 05:03 AM.
Reply With Quote
  #10  
Old 10-18-2018, 05:43 PM
kateabode kateabode is offline Help with Inserting External Information into Document Consecutively Windows 7 64bit Help with Inserting External Information into Document Consecutively Office 2016
Novice
Help with Inserting External Information into Document Consecutively
 
Join Date: Sep 2018
Posts: 16
kateabode is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
This problem got the better of my curiosity and on simplifying the code to avoid all those interminable sections relating to check boxes and bookmarks, it seems that recording the data from content controls in the bookmarked sections (provided the content controls are uniquely named) is fairly simple using a collection to hold the names and values.

Thus you can recall the userform to add a section and retain the inserted content control values. It won't of course restore ad hoc text. If you want to edit the bookmarked texts you'll need to add the content controls to hold the edits to the data document.

There are tools available from my web site to insert content controls easily and to ensure they are uniquely named.
Thanks Graham but unfortunately that won't work as I need to keep the ad hoc text. I appreciate your time and assistance thus far
Reply With Quote
  #11  
Old 10-18-2018, 05:44 PM
kateabode kateabode is offline Help with Inserting External Information into Document Consecutively Windows 7 64bit Help with Inserting External Information into Document Consecutively Office 2016
Novice
Help with Inserting External Information into Document Consecutively
 
Join Date: Sep 2018
Posts: 16
kateabode is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
The method 3 I suggested whereby each bookmark's range can be hidden is the only one that works with your described requirements. Have you tried that yet?

The bookmarks cannot be completely emptied (because the order will become confused) but they could contain only a paragraph mark which can be hidden.
Hi Guessed, thanks for your assistance. I'm not sure how to do this. Do you know the code that would help me to hide the each bookmark?
Reply With Quote
  #12  
Old 10-18-2018, 06:45 PM
Guessed's Avatar
Guessed Guessed is offline Help with Inserting External Information into Document Consecutively Windows 10 Help with Inserting External Information into Document Consecutively Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,967
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Here is some aircode that might get you started. I'll assume that you use the checkbox Tag property to store the associated bookmark name
Code:
Dim aCtl as MSForms.Control
For Each aCtl In Me.Controls
  Select Case TypeName(aCtl)
    Case "CheckBox"
      If ActiveDocument.Bookmarks.Exists(aCtl.Tag) then
        ActiveDocument.Bookmarks(aCtl.Tag).Range.Font.Hidden = Not aCtl.Value
      End If
  End Select
Next aCtl
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #13  
Old 10-21-2018, 06:09 PM
kateabode kateabode is offline Help with Inserting External Information into Document Consecutively Windows 7 64bit Help with Inserting External Information into Document Consecutively Office 2016
Novice
Help with Inserting External Information into Document Consecutively
 
Join Date: Sep 2018
Posts: 16
kateabode is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
Here is some aircode that might get you started. I'll assume that you use the checkbox Tag property to store the associated bookmark name
Code:
Dim aCtl as MSForms.Control
For Each aCtl In Me.Controls
  Select Case TypeName(aCtl)
    Case "CheckBox"
      If ActiveDocument.Bookmarks.Exists(aCtl.Tag) then
        ActiveDocument.Bookmarks(aCtl.Tag).Range.Font.Hidden = Not aCtl.Value
      End If
  End Select
Next aCtl
Thanks for your help.

Can you help me understand the code? Also, where in the code do I write the name of the bookmark associated?
Reply With Quote
  #14  
Old 10-21-2018, 06:45 PM
Guessed's Avatar
Guessed Guessed is offline Help with Inserting External Information into Document Consecutively Windows 10 Help with Inserting External Information into Document Consecutively Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,967
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Kate
You said you have a userform with checkboxes. In that userform, you can select a checkbox and see its properties in the Properties Window. There is a property called Tag. Set the value of this property to match the name of the bookmark which should show when that checkbox is ticked.

The code I supplied should sit in the subroutine that runs when the user clicks a button to dismiss that userform (ie after they tick the checkboxes they want). The code loops through all the objects on the userform and if it finds a checkbox with a tag property that matches a bookmark that exists in the document, it either hides or shows that text based on the value of the checkbox.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #15  
Old 10-21-2018, 07:20 PM
kateabode kateabode is offline Help with Inserting External Information into Document Consecutively Windows 7 64bit Help with Inserting External Information into Document Consecutively Office 2016
Novice
Help with Inserting External Information into Document Consecutively
 
Join Date: Sep 2018
Posts: 16
kateabode is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
Kate
You said you have a userform with checkboxes. In that userform, you can select a checkbox and see its properties in the Properties Window. There is a property called Tag. Set the value of this property to match the name of the bookmark which should show when that checkbox is ticked.

The code I supplied should sit in the subroutine that runs when the user clicks a button to dismiss that userform (ie after they tick the checkboxes they want). The code loops through all the objects on the userform and if it finds a checkbox with a tag property that matches a bookmark that exists in the document, it either hides or shows that text based on the value of the checkbox.
thank you so much. That's very helpful indeed!
I've added it to the code for the command button however it doesn't seem to have worked. The bookmarks are still there. I have attached the form for you to see.
Attached Files
File Type: docm Form.docm (114.4 KB, 6 views)
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Inserting External Information into Document Consecutively Number every other page consecutively fredhinke Word 1 11-11-2016 01:30 PM
Help with Inserting External Information into Document Consecutively Import external font to Word document Patrick_87 Word 3 07-17-2015 01:04 AM
how to put three videos in PowerPoint 2013 and have them play consecutively historyb PowerPoint 0 10-16-2014 11:42 AM
number every second page consecutively acrimin Word 7 06-05-2013 05:59 AM
Help with Inserting External Information into Document Consecutively Automatically inserting information into report joughin Word 3 05-15-2012 09:12 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:20 PM.


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