Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-10-2018, 09:56 PM
liliaroma liliaroma is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Nov 2017
Posts: 14
liliaroma is on a distinguished road
Smile How to add or hide automatically 500 “Heading 4”?

Hi there,



I have a question of adding the “Ingredients” part formatted in Heading 4 for many recipes. But first of all, for the clearness, I will describe my job.

My job is cookbook publishing so I have to work with a huge number of cooking recipes. I often hire freelancers to rewrite the recipes. However, for keeping the copyright and preventing freelancers from taking my recipes, I often delete the part of “Ingredients” formatted in Heading 4. With the help of the administrator on this web, I could delete these with one click by the code of Macros program: https://www.msofficeforums.com/word-vba/37364-how-delete-automatically-500-heading-4-all.html. I am very thankful to the administrator for the help.

Now, I have a question that after the freelancers send my rewritten files, Is there any quick method to add the “Ingredient” part again to the rewritten files to publish them? I still often do it manually (copy & paste) and it takes a lot of time. I thought a lot and had 2 following ideas:
  1. Is there any ways in Microsoft Word 2013 that I can add all the deleted “Ingredient” parts by the code of Macros program above?
  2. Another idea is that I will hide the “Ingredient” parts and freelancers cannot see or open these (I am not sure it has this program or not lol) and then I send the freelancers. When they finish it and send it to me, I will make the “Ingredient” appear to publish.
Attached Images
File Type: png Screenshot_1.png (223.9 KB, 24 views)
Attached Files
File Type: zip 20 Reicpes [Sample].zip (1.36 MB, 16 views)
Reply With Quote
  #2  
Old 04-11-2018, 01:17 AM
slaycock slaycock is offline Windows 7 64bit Office 2016
Expert
 
Join Date: Sep 2013
Posts: 255
slaycock is on a distinguished road
Default

There are a number of ways you can do this.

1. Save the ingredients as a separate word file and then use an includetext field to reinclude the ingredients. Thus your document will show the ingredients but the freelancer will not.

2. Use macros to move the ingredients section to custom xml. Keeps the ingredients in the file in an invisible format (but which could be viewed if someone knows they are stored as xml.
Reply With Quote
  #3  
Old 04-11-2018, 01:52 AM
liliaroma liliaroma is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Nov 2017
Posts: 14
liliaroma is on a distinguished road
Default

Thanks a lot for your support. Could you explain more about your first method? Or you can give me a detailed example for the clearness. Because in the second one, I do not know anything about coding. I am just a content creator

Last edited by macropod; 04-11-2018 at 09:49 PM. Reason: Deleted unecessary quote of entire post replied to
Reply With Quote
  #4  
Old 04-11-2018, 02:44 AM
slaycock slaycock is offline Windows 7 64bit Office 2016
Expert
 
Join Date: Sep 2013
Posts: 255
slaycock is on a distinguished road
Default

For a start you might gogle 'Word includetext' which would pull up many references including

https://wordmvp.com/FAQs/TblsFldsFms...textfields.htm

I've attached your sample file where I've modified the text to use an include text field for the first three sets of ingredients.

When saving the ingredients as a seperate file make sure you delete the final paragraph markers otherwise this will appear in the imported text.

When you insert the field your usage means that you want to make sure that the 'Preserve formatting during updates' checkbox is unchecked.

The field is inserted using

Insert.Quick Parts.Field....
Scroll down to find Include Text and select it
Add the file path/name
Uncheck 'Preserve foprmatting during updates'
Click OK
Attached Files
File Type: zip 20 Reicpes [Sample] with ingredients.zip (1.39 MB, 15 views)
Reply With Quote
  #5  
Old 04-11-2018, 03:12 AM
liliaroma liliaroma is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Nov 2017
Posts: 14
liliaroma is on a distinguished road
Default

Hi,
I read fully your instructions and thanks for that. But I have a question that is in the attachment. How could you do this? You did this manually or by an automatic method?
Attached Images
File Type: png Screenshot_2.png (66.3 KB, 23 views)

Last edited by macropod; 04-11-2018 at 09:48 PM. Reason: Deleted unecessary quote of entire post replied to
Reply With Quote
  #6  
Old 04-11-2018, 03:23 AM
slaycock slaycock is offline Windows 7 64bit Office 2016
Expert
 
Join Date: Sep 2013
Posts: 255
slaycock is on a distinguished road
Default

In this instance manually. It would be relatively simple to craft a macro to do this job but I didn't go that route as you indicated that your experience wouldn't lend itself to installing and running a macro.

If you are a commercial operation then maybe someone in your IT support would have the skills to do this for you.
Reply With Quote
  #7  
Old 04-11-2018, 03:08 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

This seems to be a very round-about approach to something that could be handled by formatting the 'Heading 4' Style as hidden text, along with whatever other Style is used for the ingredients...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 04-11-2018, 07:30 PM
liliaroma liliaroma is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Nov 2017
Posts: 14
liliaroma is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
This seems to be a very round-about approach to something that could be handled by formatting the 'Heading 4' Style as hidden text, along with whatever other Style is used for the ingredients...

Thanks for your reply. Can you explain more about the method? Or could you please suggest me a macro to do this problem automatically?
Reply With Quote
  #9  
Old 04-11-2018, 08:10 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Instead of using the 'Heading 4' and 'List Bullet' Styles throughout, had you used a unique Style name for both the 'Ingredients' headings and the ingredients themselves, all you would have to do is to change those Styles' text format to hidden or not-hidden, as desired. You can do that via Styles>Down Arrow>Style Name>Modify>Format>Font. No macros would be needed, though a quite simple macro could be used to do both:
Code:
Sub ShowHideIngredients()
Application.ScreenUpdating = False
With ActiveDocument
  With .Styles("Ingredients").Font
    .Hidden = Not .Hidden
  End With
  With .Styles("IngredientItems").Font
    .Hidden = Not .Hidden
  End With
End With
Application.ScreenUpdating = True
End Sub
where 'Ingredients' and 'IngredientItems' are the names of the Styles concerned.

As it is, a far simpler macro than you've already been given could be used to toggle the 'Ingredients' display on/off:
Code:
Sub ShowHideIngredients()
Application.ScreenUpdating = False
Dim RngHd As Range
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "Ingredients"
    .Style = wdStyleHeading4
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = True
    .MatchCase = True
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute
  End With
  Do While .Find.Found
    Set RngHd = .Paragraphs(1).Range
    Set RngHd = RngHd.GoTo(What:=wdGoToBookmark, Name:="\HeadingLevel")
    RngHd.Font.Hidden = Not RngHd.Font.Hidden
    .Start = RngHd.End
    .Find.Execute
  Loop
End With
Set RngHd = Nothing
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 04-11-2018, 09:45 PM
liliaroma liliaroma is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Nov 2017
Posts: 14
liliaroma is on a distinguished road
Default

That's great. Thank you very much, admin. Now I can show/hide Ingredients with just one click. I think my problem has been solved. Hoping the forum will grow more and more.

Last edited by macropod; 04-11-2018 at 09:47 PM. Reason: Deleted unecessary quote of entire post replied to
Reply With Quote
  #11  
Old 04-11-2018, 09:47 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You're welcome. However, please don't quote every post you reply to - all that does is add clutter. If there's a particular part of a post you need to discuss, quote just that part.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #12  
Old 04-12-2018, 03:24 AM
slaycock slaycock is offline Windows 7 64bit Office 2016
Expert
 
Join Date: Sep 2013
Posts: 255
slaycock is on a distinguished road
Default

Maybe I've misunderstood.

If you toggle the visibility of the ingredients then that text is still present when the document is sent to a freelancer. Thus the ingredients text may be viewed and /or corrupted by editing done by the freelancer.

With my macros you create your source document with the ingredients then before you send to a freelancer you run my macros to convert the ingredients text to an include text field.

When the freelancer receives this document, the include text fields will show as an error because the ingredients source documents are not present on their system. This makes it safer for the freelancer to edit the document without touching the broken includetext field.

When you get the edited document back, you place it in the same directory as the original document and then do a select all and F9 to update the document. This will reload all of the ingredient files.

You can emulate this process by copying your recipe document to a different directory. When you open the document to edit it you will see the include text fields showing an error. Edit the document avoiding changes to the includetext fields, save under a new name, copy back to the original directory, open the document and refresh it as described above, and the include text fields will again show the ingredients.

Once you have finished with the freelancers editing the document and you are ready to use it further for the publishing process, you select the whole document and do a control+F( to convert the include text fields back to text.
Reply With Quote
  #13  
Old 04-12-2018, 01:54 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by slaycock View Post
When the freelancer receives this document, the include text fields will show as an error because the ingredients source documents are not present on their system.
That's not necessarily so; it all depends on whether the recipient has the 'Update automatic links at open' option checked.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #14  
Old 04-12-2018, 04:56 AM
liliaroma liliaroma is offline Windows 7 64bit Office 2013
Novice
 
Join Date: Nov 2017
Posts: 14
liliaroma is on a distinguished road
Default

@slaycock Thanks for your really awesome idea! If the idea runs successfully, it is very safe for me to send the file for freelancers.

I followed your instructions but when I copy the recipe document to a different directory, the include text fields did not show as an error. I recorded my working process in the following video. I really hope you will see it and give me some recommendations. Thanks a lot.

Video: https://youtu.be/yBxfzfL-RK0
Reply With Quote
  #15  
Old 04-12-2018, 05:14 AM
slaycock slaycock is offline Windows 7 64bit Office 2016
Expert
 
Join Date: Sep 2013
Posts: 255
slaycock is on a distinguished road
Default

That's because I made recommendation without thinking clearly.

The includetext fields are setup using an absolute path. This means that if you just move to any other directory on your PC it will still work. APologies for that bad (recommendation, not the file path).

Instead try the original file on a second PC and you will see what I intended.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find instances of heading text in the body of my doc, make cross reference to the actual heading MAHE Word VBA 4 03-03-2018 07:59 AM
How to delete automatically 500 “Heading 4” and all the contents in this from Navigation? liliaroma Word VBA 4 11-18-2017 07:53 PM
How to Hide/Un-hide a worksheet based on cell on another sheet. easton11 Excel Programming 1 06-02-2015 12:07 PM
Creating a table that automatically updates based on entries of a heading in the document cahphoenix Word 3 10-29-2014 01:11 PM
How to have a heading 1 file automatically appear in each header of any page? expert4knowledge Word 2 09-16-2012 10:38 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:08 AM.


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