Number and letter numbering of tables in word with cross-referencing - ms-word

How do I get a smart numbering system as shown below? Whenever I have a new table, I want the numbering to rise.
If, on the other hand, I add a row to the table, I would like to add a letter in behind the numbering.
Is this possible?
I have startet using Field Codes and Sequences, and I believe it is the way to go.
I know the numbering without the letters can be obtained by
Number #{ STYLEREF 1\s}{SEQ Table \# "00"}
I also know that alphabetic numbering can be made by using the \alphabetic command.
I am just not sure how to combine them. Also, I would like to make cross-references to the table captions.

You can achieve this with Word's built-in numbering - no need to resort to a complex combination of fields that you'll need to manually update.
I'm going to outline the very complete approach...
On the Home tab: Paragraph/Multilevel list/Define new list style.
Enter a name for the style, then from the Format button choose Numbering; click More.
With Level 1 selected, choose the style with which you want to link the numbering (Heading 1, for example)
In the "Enter formatting for number" field type any text you want to have appear before or after every number. (According to your picture: Header in front of the number 1 with grey shading already in the box.)
Select Level 2, choose the style with which you want to link the numbering (Heading 2, for example)
In the "Enter formatting for number" field type in front of the number (2, grey shading): Number #00
From the "Include level number from" dropdown, select level 1. The number from Level 1 will be inserted between the last 0 and the grey-shaded 2.
If necessary, change the alignment settings (you probably don't want the indent inside the table cell?)
Now, when you apply the Heading styles the numbering will be applied automatically. If you don't like the formatting of the Heading styles you can change the style definition(s). Since you created a numbering style, you can also change these settings by going again to the Multilevel numbering dialog box, right-clicking the numbering format you created and selecting "Modify".

I believe the following field code approach will give you the numbering indicated in your sample image (where the table numbering restarts for each Heading 1 paragraph. However, it will probably only work for "in-line" tables, not floating tables or tables in text boxes and so on.
The main aim here is to ensure can insert exactly the same field codes for each new "Number#" that you need, but to achieve that you also have to put some codes at the beginning and end of each table. You will also need to select and re-execute all the field codes twice to ensure that they are updated properly - this is the kind of disadvantage that Cindy Meister's Answer mentions.
At or before the beginning of each table, put the following fields. (If you are already putting a table caption before each table, you could do this slightly differently.)
{ SEQ tbl \s 1 \h }{ SEQ ltr \r0 \h }
This increments the table number, resetting at each Heading 1 paragraph, and resets the letter number to 0.
For every "Number #" you want in a table, use the following fields:
Number #{ STYLEREF 1 \s }{ SEQ tbl \c #00 }{ SEQ ltr \h }{ IF { REF "chap{ STYLEREF 1 \s }tbl{ SEQ tbl \c }" } > 1 "{ SEQ ltr \c \*alphabetic }" "" }
This inserts the appropriate Heading number and the table number, and increments the letter number. It then looks at a bookmark that contains the number of "Number #" entries in this table. For example, if Heading 1 is numbered 4, and this is the thrid table under that heading, the bookmark will be called "chap1tbl4". If the bookmark's value is greater than 1, the appropriate letter will be appended.
But we have to create that bookmark and value, which we can only do after all the "Number #" fields for that table. So at the end of each table, or immediately after the table and before any new Heading 1 paragraph, you will need the following field codes:
{ SET "chap{ STYLEREF 1 \s }tbl{ SEQ tbl \c }" { SEQ ltr \c } }
The thing is that Word evaluates field codes in the sequence they appear in the document. So when Word first encounters the { REF } field in the table, the bookmark will have no value. So the first time you select all the fields and execute them, you may see the wrong answer. After you have done that, the bookmark is created. Word will use the value most recently assigned to the bookmark, so the next time you execute the "Number #" fields, they should work properly.
I think to achieve what you wanted using the general approach given in Cindy Meister's Answer, you would need to have two separate Heading levels, one for the Numbers without letters,and another for the numbers with letters. The user, or some VBA (say) would then have to decide for each table which Heading level to use. But even if that is the case (and she may have something else in mind), it may still be an operationally simpler approach than the field-based one. I suspect only you are in a position to decide.
There may be a simpler field-based formulation, but IME the basic problem is that you cannot test the "final value" of a SEQ or SET field, only the value it has at the point of execution. For example, if there was a \f flag that let you test the final value of a SEQ field, you could use
{ IF { SEQ "chap{ STYLEREF 1 \s }tbl{ SEQ tbl \c }" \f } > 1 .... }
to test the number of "Number #" entries in each table, without having to have that awkward end-of-table SET field.

Related

In MS Access, how a control can displays a value based on a field selection using a combo box that displays a Field list?

I have a table like this one :
This table represents a species (No = 3) and the number of individual for the last 6 years. (FYI, the table cannot be displayed differently.)
I created a Combo Box which displays the last 6 years (based on a field list).
What I have to do so that the turquoise rectangular automatically displays "31", for example, if the year "2014" is selected?
The question doesn't contain enough detail about the host form and other bound controls, so the following is just a pattern to follow.
Set the Control Source of the turquoise (i.e. cyan) control to something like
= DLookup("[" & comboboxYear.Value & "]", "TableName", "ELEMENT_ID=" & [ELEMENT_ID])
This assumes that there is a bound control named [ELEMENT_ID] on the form. Brackets wrap the ComboBox value to ensure the value is interpreted as a column name and not a number.

How to increase visual length of form text field in Word?

When a form text field is inserted in a Word document, the grey shaded length is about 5 characters long. How can this length be increased?
Allthough it is a rather crude measure (and I don't recommend it), you can set "Properties -> Default Text" to as many blanks as you want the size. But this comes for a price: as long as you move into the field by pressing TAB, all blanks are selected and get typed over. When you use the mouse, you click the cursor anywhere into the field and start typing ... so your entry might be pre and post fixed by a number of blanks that you have to trim away in e.g. an exit macro.
I recommend old form fields as the last resort (i.e. there must be a good reason to use them) and would prefer (in that order)
native Word2010/2007 fields (text or Rich text - perhaps not backwords compatible)
legacy ActiveX fields (compatible with W2003)
Legacy (old) form fields

How to select and modify all caption fields at once in a Word document?

I have been trying to change the numbering style of my figure and table captions. All of my headings are in Roman numerical. However, I want Arabic numerical in my caption numbering. Could anyone tell me an easy way to do it at once? Below is an example:
Heading title: "Chapter V". My captions appear as "Figure V-2". However, I want them to appear as "Figure 5-2"
Also, is there any way I can select all figure caption fields at once and edit their field code?
To change in one caption: Press Alt-F9 and remove \* ARABIC .
Ctrl+A, F9 to update fields.
Now to change in all captions: try with a search and replace (Ctrl+H) to replace SEQ Figure \* Arabic \s 1 with SEQ Figure \s 1
To modify all field codes, you could use search & replace or you can modify field codes in VBA this way:
Sub ChangeAllFields()
'does not process headers/footers
Dim oFld As Field
For Each oFld In ActiveDocument.Fields
fld.Code = Replace(fld.Code, "SEQ Figure \* ARABIC \s 1", "SEQ Figure \s 1")
Next oFld
End Sub
When you insert captions from now on, change the numbering in the dialog box that pops up. I think you'll have to change it every time, because Word (correctly) defaults to matching the Roman numerals in your chapter headings to Roman numerals in your captions. If you want to be abnormal, you'll have to change from the default every time you insert a caption, or change them all using one of the methods from Toon Flores.
p.s. I said "abnormal" because every style manual I've ever seen would frown on what you are doing.

Libreoffice/Openoffice Calc - append string to cells

I need to add .jpg at the end of all he cells in one or more columns
9788895249971 into > 9788895249971.jpg
9788867230129 into > 9788867230129.jpg
9788867230273 into > 9788867230273.jpg
9788867230280 into > 9788867230280.jpg
Detailed step-by-step instructions are much appreciated since I am very new to Calc.
Thanks
Do you need to do this once or is this going to be a repeated task every week/month?
If it is something you need to do just once, here is what you can do:
Next (right) to the column where your numbers are open (insert) a new column.
Assuming the following: Numbers are in column A, New column is column B.
In this new column B in the top cell (B1) write:
=A1&".jpg"
Now copy B1 all the way down to the end. In B1 type [Ctrl]+c then Hold [Shift] and hit [PgDn] until the end then press [Ctrl]+v.
Highlight Column B, [Ctrl]+c, then [Edit] [Paste Special] values only (No formula's) this freezes the calculated data.
This is just another option,
just click the function wizard and select concatenate, in that enter which column you want to enter as text1 as and second column in text2. Then when you click OK you will get an concatenated column like below image
so in the C column you will get as a1.jpg.
For those who continue to find this question (as I did):
This can be quickly done using regular expression option of find and replace. (I don't know what version of Calc introduced regex searches, but 6.2.4 has it.)
If you only want to update some non-blank cells on the sheet, select them.
Choose Find and Replace.
On the dialog, fill in the following:
Enter $ for the Find value. ($ means end of line in regex, or in this context end of cell value.)
Enter the desired suffix (.jpg in the question) for the Replace value.
Check Regular Expressions under Other Options
Check Current Selection Only under Other Options if you want to limit to the cells selected in step 1.
Uncheck All Sheets unless that is what you want.
Choose Replace All
This will update the values in-place and does not require any additional columns or formulas.
There's a much more elegant way to do this that doesn't require sacrificing cells just to hold data types, and can be scaled to work with one cell or a large chart range.
Add both pieces of data into the =CONCAT() function
Make sure to use CONCAT instead of CONCATENATE, as `CONCAT accepts cell ranges and is more dynamic.
Open the Function Wizard on the cell in question, and build the following function:
=CONCAT(<your_data>," <suffix>",...)
# Make sure to add a space before the suffix so it appears in the cell.
# You can use this with as many input variables as required letting
# you add as many strings, formulas, or numbers together.
The result should be something like this. In my example, the cell in question is the final value of Ethereum on a balance sheet:
The above example was an easy one, since it was being used as a test, all my summed values were ints, if I had floating point numbers, they would run away to max decimal places (not very pretty).
The function will drag out and expand intelligently to other cells like any other formula.
Adjusting accuracy of floating point values inside a CONCAT function
Sometimes, adding a cell results in a rounding problem, or an extreme amount of decimal places. You can further nest your function using ROUND(<your_data>,<decimal_places>)
Your function would look like this:
=CONCAT(ROUND(<cell_range>, ".jpg")
In your specific case, you don't need a space in the second argument as you want to append .jpg directly to the end of the string.
`
Using Macros to automate the entire process
This is extremely repeatable, and using the Macros feature, you can automate these to make much more simplified functions that allow you to enter just the variables you need, while the macro does the work in the background.
Based on Emmanuel Angelo R.’s answer, I would advice learning to differentiate between fixed cell references and dynamic ones. The following applies:
Cell A1 contains the suffix you would like to add, e.g. ‘.jpg’
Row 2 contains headings, e.g. B2 = ‘Old Filename’ and ‘New Filename’
Cells A3:A¹ contain your filenames
Cells B3:B contain you concatenation formula
In cell B3, type =concatenate(A3;$a$1).² If your locale requires comma as separator, replace my semicolons with commas. Copy cell B3 by selecting it and pressing Ctrl + C. Move the cursor to cell A3, press Ctrl + ↓ (down arror on your cursor keys); this will move you to the bottom of the list of file names. Move your cursor right, then press Ctrl + Shift + ↑; this will select all cells up to the last cell with contents (the one you just wrote your formula in). Press Ctrl + V to paste your contents.
Adding dollar signs in front of your row/column coordinates, will lock that coordinate when pasted. Say you had a list of file types in cells b1–z1 (e.g. jpg, jpeg, tga, bmp, png et c.). An easy way to create the formula would then be by first typing it in cell B3 as =concatenate(A3;B$1), then paste it to every cell till the end of your file names list (cell z3); these cells would then read …A3;b$1, …A3;C$1 et c. When copying it for all the rows below
You could select the entire range of cells with formulas in row 3 and run a search and replace, replacing all instances of ‘A3;’ by ‘A3;$’, effectively inserting a dollar in front of all the cell references, allowing you to, should the need arise, copy it horizontally as well as vertically (the latter being covered by the $ in front of 1).
¹ This means cells from A3 and however far down your sheet goes
² Strictly speaking, it is only necessary to type it as a$1.

How to do search and replace involving fields in Microsoft Word?

I have a Word document with fields of the reference variety, which occur in the form "[field].[field]"--in other words, there's a period between the two fields. I want to globally replace this with a space.
Word offers the ^d special character to search for fields, but for some reason the query "^d.^d" does not find anything. However, ".^d" does. Now comes the problem, however--what do I specify as the replacement text in order to retain the field code? If using regular expressions, I could use a "Find What Expression" such as \1, but with regexp ("wild card") mode the ^d is not permitted.
I guess I could write a macro...
I would like to add to Bibadia's solution.
An example of an index entry field; we want to change a name we misspelled.
Make sure hidden formatting is displayed (toggle with SHIFT+CTRL+F8).
Make sure wildcards option is not selected. To search for fields, use the opening and closing field braces code (optionally use ^w for spaces, as Bibadia suggested):^19 XE "Deo, John" ^21
Replace won't recognize field braces character, but will allow to insert the clipboard's content. ;). To do that, insert in text the correct entry. CTRL+F9 to insert field and type:XE "Doe, John"
Select the field above and copy
Use ^c in the replace box
Hit Replace All
Ta-da!
It's usually better to go the macro route when finding fields because, as you say, the find algorithm that Word uses doesn't work the way you might hope with fields.
But if you know exactly what the fields contain, you can specify a search pattern that will probably work (however not in wildcard mode).
For example, if you want to look for figure number field pairs such as
{ STYLEREF 1 \s }.{ SEQ Figure \* ARABIC \s 1 }
(which would typically be the same set of fields everywhere in the document)
If you only really need to look for the following:
{ STYLEREF 1 \s }.<any field>
you could ensure that field codes are displayed and search for
^d STYLEREF 1 \s ^21.^d
or
^19 STYLEREF 1 \s ^21.^19
If you need to be more precise, you can spell out the second field as well.
"^d" only works for finding the field beginning, not the field end.
It's a shame that ^w wants to find at least 1 whitespace character because otherwise it would be more robust to look for
^19^wSTYLEREF^w1^w\s^w^21.^19
Perhaps someone else knows how to work around that without using wildcards?
Torzaburo,
I suggest that you do this using a macro. You can start by recording the macro, and later refining your processing steps within the macro.
First turn on the hidden characters by navigating to Home > Paragraph > toggle the show/hide Paragraph symbol. Also, select all and toggle the field codes on (right-click and select "Toggle Field Codes".
Open a new blank Word doc in addition to the one you have open. You will use this later. Start the macro recording and find the field using the "^d" (field code) as you said.
When the field is found, copy only the field text within the brackets, and not the full field reference. While the macro is still recording, ALT + TAB to the new blank document and paste the field code in as plain text.
At this point, do the necessary find & replace processing to the field codes. Highlight the processed field codes, copy, ALT + TAB back to the original document, and paste back between the { } brackets.
Stop the macro recording. Add any further custom processing to the macro VBA.
Select-All and re-toggle the field codes. Update the field codes.
You don't need a macro. Just toggle all field codes on by using Alt+F9. Then do a find and replace for what you want to change. Once the replacement is complete, use Alt+F9 again to toggle the field codes back off.
Disclaimer: I didn't originate this solution, but it's clean and elegant and I thought it should be included here:
(Adapted from Search & Replace Field Codes in Word):
Create or find a single instance of the field you want to convert text to
Toggle Field Codes visible (AltF9)
Copy the code for the field you want to use to the Clipboard (highlight and CtrlC)
Open the Replace dialog box (CtrlH), insert the text you want to replace in the Find What box and then enter ^c in the Replace With box.
This will replace your text with the contents of the Clipboard, turning it into the field code you copied in step 3. It also copies formatting information (font, color, etc.), to control how the field will appear when hidden. (Caveat: I've tested this with Word 2003 under Windows 7 only.)
Coming in late on this, probably way too late for Beth (sorry Beth). And this may not be quite what Beth was looking for. But for anyone interested ...
It sounds like Beth may have created captions throughout the document using INSERT CAPTION (hence the presence of field codes). This means these captions will have been (automatically) created in CAPTION style.
To globally replace the separator "." with " " (space) in such captions, take two steps:
[1] Go to REFERENCES | INSERT CAPTION, then click on NUMBERING and replace the SEPARATOR "." with "EM-DASH". This will replace all separators in captions for the selected label in the CAPTION Window. If you have other labels in use in the document (e.g. FIGURE), select the other labels one by one and repeat this process.
[2] Do a find/replace searching for special character "em-dash" (^+) in style CAPTION, replacing with " ". Click REPLACE ALL.
Voila!
NOTE: This presumes that em-dash does not appear in the caption text anywhere. If it does, then you'll need to do a pre- and post- "fiddle" to ensure these em-dashes are not touched by the global replace above.
The "pre-fiddle" is to do a global find/replace across captions, replacing the em-dash ("^+") with some other string (e.g. "EM-DASH") that doesn't ever occur in any caption's text. Then you do the separator change as described above. Finally, the "post-fiddle" is to restore the em-dashes that were in the captions, by doing a global replace of the string "EM-DASH" with the actual em-dash character "^+".