![]() |
|
#1
|
|||
|
|||
![]()
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:
|
#2
|
|||
|
|||
![]()
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. |
#3
|
|||
|
|||
![]()
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 |
#4
|
|||
|
|||
![]()
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 |
#5
|
|||
|
|||
![]()
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? Last edited by macropod; 04-11-2018 at 09:48 PM. Reason: Deleted unecessary quote of entire post replied to |
#6
|
|||
|
|||
![]()
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. |
#7
|
||||
|
||||
![]()
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] |
#8
|
|||
|
|||
![]() Quote:
Thanks for your reply. Can you explain more about the method? Or could you please suggest me a macro to do this problem automatically? |
#9
|
||||
|
||||
![]()
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 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] |
#10
|
|||
|
|||
![]()
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 |
#11
|
||||
|
||||
![]()
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] |
#12
|
|||
|
|||
![]()
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. |
#13
|
||||
|
||||
![]()
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] |
#14
|
|||
|
|||
![]()
@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 |
#15
|
|||
|
|||
![]()
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. |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
MAHE | Word VBA | 4 | 03-03-2018 07:59 AM |
![]() |
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 |
![]() |
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 |