Archive for August, 2011

h1

Word: Macro to insert a formatted table and an automated caption

August 10, 2011

NOTE: These instructions only work for Word 2007 and later; they use Building Blocks, which are only available in these versions of Word. If you are using Word 2003 or earlier, I hope to share a much longer macro with you in a few weeks that does something similar but without the formatting.

Scenario

You need to make it easy for your authors to insert many tables in their documents. So you need to add something to the template that allows them to press a couple of keys and get both a preformatted table and an automated caption inserted.

The tables all need to be formatted the same — same header row shading, height alignment and style; same border color and width; same table row height, alignment and style. Once they’ve inserted a table, the author has to be able to modify it (e.g. merge cells) without those modifications affecting anything else.

Your template uses outline heading numbering, so you want a table caption to be inserted at the same time as you insert the table. The caption is to include the chapter number and a sequential caption number (e.g. if they’re in section 2, you want the tables they insert in section 2 to be numbered Table 2-1, Table 2-2 etc.).

Solution

While Quick Tables are an option, you won’t get the caption inserted with them. So this solution takes Quick Tables a couple of steps further. UPDATE 2016: You *can* get the caption inserted with a Quick Table — you just have to select the table AND its caption when creating it and the caption is added automatically (and adjusts the table numbering) when you insert the Quick Table. This solution may be better for those who don’t want to fiddle with macros and code — it’s very much quicker too. If you go that route, you don’t need to read any further.

Step 1: Set up the table

  1. Open your Word template — the template itself, NOT a document based on the template.
  2. Create a table in your template and format it as you want. I suggest you create a table that’s four column by five rows — authors can add/remove rows and columns later.

When creating your table, make sure you:

  • apply the relevant styles to the table header row and the table rows
  • set the row heights for the table header row and the table rows
  • set the alignments for the table header row and the table rows
  • apply shading to the table header row
  • set the table header row to repeat across pages (if required)
  • apply table borders — line styles, color, and widths
  • do whatever else is required to make your table follow your corporate style.

Step 2: Save the table as a Building Block

  1. Select the entire table.
  2. Go to the Insert tab > Quick Parts.
  3. Select Save selection to Quick Part gallery.
  4. In the Create New Building Block dialog box, give the selected table a unique name (e.g. corporate_table).
  5. Change the Save in location from the default Building Blocks.dotx to your template (e.g. corporate_template.dotm). If your template is not listed, then you didn’t create the table in your template — start again at Step 1: Set up the table. Changing the saved location is CRITICAL as you want to share this table with all users of your template; as far as I know, Building Blocks.dotx is a local file on each person’s local machine and it’s not easy to transfer building block entries from one machine to another.
  6. Click OK.
  7. Delete the table from your template, if required.
  8. Save the template but don’t close it.

Step 3: Create a macro that inserts the table and its caption

  1. Go to the Developer tab. (Here’s how to turn it on in Word 2007 and Word 2010.)
  2. Click Macros.
  3. Type Table in the Macro Name field at the top of the Macros window.
  4. Click the drop-down box for Macros in and change the setting to your template (e.g. corporate_template.dotm (template)).
  5. Click Create.
  6. Copy the code in the yellow box below — copy it all; some is not displayed fully, so make sure you drag your cursor over the entire set of code when you copy it.
  7. In between Sub Table() and End Sub, paste the code you just copied.
  8. Make any changes required. You’ll need to change the name of the BuildingBlockEntries from “corporate_table” to the name of your Building Block. Other suggested changes are listed below the macro.
  9. Close the Visual Basic window and save the template (don’t close it yet).
' Insert Table from Building Blocks in template, insert auto caption with chapter numbering
'
'
With CaptionLabels("Table")
        .NumberStyle = wdCaptionNumberStyleArabic
        .IncludeChapterNumber = True
        .ChapterStyleLevel = 1
        .Separator = wdSeparatorHyphen
End With

    Selection.InsertCaption Label:="Table", TitleAutoText:="", Title:="", _
        Position:=wdCaptionPositionAbove, ExcludeLabel:=0
    Selection.TypeText Text:="   <Table Title>"
    Selection.TypeParagraph 

    ActiveDocument.AttachedTemplate.BuildingBlockEntries("corporate_table" _
      ).Insert Where:=Selection.Range, RichText:=True

Other changes you might want to consider:

  • This code has a hyphen (wdSeparatorHyphen) as the separator between the chapter number and the sequential table number — you can change it to something else. These options are available: wdSeparatorColon, wdSeparatorEmDash, wdSeparatorEnDash, and wdSeparatorPeriod.
  • When the caption is inserted, it automatically adds three spaces after the table number and inserts <Table Title>, which is selected ready for the author to change it — if you don’t want the three spaces, or the text, change them within the double quote marks on the Selection.TypeText Text:=”   <Table Title>” line.

Step 4: Assign the macro to a key combination

To make it easier for your template’s users, assign this macro to a key combination so they can just press a couple of keys to get a formatted table with its caption inserted every time.

  1. Open the relevant Customize window:
    • Word 2007: Office button > Word Options > Customize (or click the little drop-down arrow to the far right of the Quick Access Toolbar)
    • Word 2010: File > Options > Customize Ribbon.
  2. At the bottom of the left panel, click the Customize button.
  3. Scroll down the Categories list (on the left) to the end, then select Macros.
  4. In the list of macros on the right, select Table.
  5. Click in the Press new shortcut key field.
  6. Press the keys you want to assign to this macro — e.g. Alt+Shift+T.
  7. Click the drop-down box next to the Save changes in field, then select your template.
  8. Click Assign.
  9. Click Close.
  10. Click OK to close the Customize window.
  11. Save your template, but don’t close it yet.

Step 5: Test!

The final step is to test that the key combination invokes the macro and that the table and its caption is inserted as you expect.

  1. Go to any blank space in the template after Heading 1, then press the key combination you assigned earlier (e.g. Alt+Shift+T) — the formatted table and its automated caption should be inserted correctly.
  2. Be daring — try another one!
  3. Now delete those tables you just added and save and close the template.
  4. Next, open a new document based on the template and test out the key combination there too.
  5. Distribute your template to your authors and let them know how to insert a table the quick way using the key combination you assigned.

[Links last checked August 2011]

h1

Word 2010: Spiffy ligatures and stylistic sets

August 9, 2011

Here’s something that moves Word 2010 from being ‘just a Word processor’ into a different typographic realm — ligatures and stylistic sets for fonts.

At the moment, not many of the Open Type fonts have stylistic sets associated with them, but now that they can be displayed in Word 2010 (NOT the earlier versions), I expect the number of font sets with these extra features will increase.

So what am I taking about?

Well, ligatures are the little bits that connect letters such as ‘f’ and ‘i’ in a word like ‘fill’, and stylistic sets offer flourishes to the letter forms. Take a look at the screen shot below:

How did I achieve this? In word 2010, I set the font of the line to Gabriola (Gabriola is one of the few Open Type fonts provided by Microsoft that comes with various stylistic sets at this stage). Then I changed the setting on the Advanced tab of the Font dialog to apply ligatures (All) and stylistic set number 6 (try other sets — you’ll see what each looks like in the little Preview window):

Then I started typing…

As you can see from the screen shots below, the letter flourishes change depending on the position of the letter in relation to the letters either side of it. And they change dynamically — this can be a little disconcerting at first as you’re not used to things moving on the screen as you type!

So, what use does this feature have? Well, for technical communicators, perhaps not a lot. But for anyone using Word to create personal communications (such as wedding/party invitations), menus, certificates, artistic communications etc. this may be a feature they use every so often (you wouldn’t want to use it everywhere!).

Add some color to the font and other formatting, and you could end up with something quite spectacular (or really awful!) — and all from Word 2010.

_______________

For an explanation about all the settings on the Advanced tab of the Font dialog, see:

More how to’s with this Word 2010 feature:

[Links last checked August 2011]

h1

Word: Insert a multi page PDF

August 8, 2011

Word is kludgy (that’s a technical term!) when it comes to inserting objects from other applications — including from other Office apps. When you insert a file as an object, only ONE page of the file is displayed in Word. Too bad if your file has multiple pages… as most do.

Carol’s problem was with a multi page PDF she had created from Excel (the original was a large text table — nothing fancy). The spreadsheet was fairly wide, and she had created the PDF using an A3 paper size. The resulting document was seven pages long. She wanted to insert it in her Word document as an Appendix but to date it had beaten her. So she asked me for help.

And that’s when I discovered that Word’s ‘Insert Object from file’ function only inserts the first page of the file. Which is just stupid. And is just useless for most people in the business world where multiple page documents are the norm. (The links below this post  confirm that only one page is inserted — most of the information in these links is from Microsoft Word MVPs, people who have much more knowledge about this stuff than I do.)

I tested several options — I was able to get the PDF into the Word document, but not without a fair bit of trial and error. In essence, you’ll save the PDF pages as images, then insert those images into Word. I told you it was kludgy!

I’ve documented some methods below — the method YOU use will depend on the software you have. If you have full Acrobat (NOT Adobe Reader), then you have a better chance of getting a decent result, than if you don’t (use Method 1). If you don’t have full Acrobat, but have graphics software that will take screen captures, then use Method 2. And if you have neither full Acrobat nor a screen capture program, then you’ll have difficulty achieving your goal of inserting a PDF file into Word (see Other Options).

Method 1: Using full Acrobat

  1. Open the PDF in Acrobat (NOT Adobe Reader).
  2. Select File > Save As from the menu (I’m using Acrobat Professional 9, but later versions should work similarly).
  3. Click the drop-down arrow next to Save as type to see the available file types.
  4. Select one of these: JPG, PNG, or TIF.
    In my testing, the results from each file type were similar — TIF had a *slightly* crisper text quality and added about 700 KB to the Word document for EACH page saved from the PDF; JPG and PNG were similar in text quality (and only marginally fuzzier than TIF in the printed output) — they added about 900 KB and 150 KB respectively per page to the Word document’s size. I suggest you do your own testing of the on screen and printed resolutions of the various file formats to find the best for you.
  5. Click Save. Acrobat will create a separate image for each page in the PDF in the folder specified on the Save As dialog; e.g. <name of document>_Page_1.png etc.
  6. Open the Word document and insert the images into the document as you normally would. If the images are large (as Carol’s were), add an A3 landscape section for the images.

Method 2: Using a screen capture program

If you have a screen capture program such as SnagIt, you can ‘print’ to it from the PDF to create the individual images. If you know the output file type you want and if want SnagIt to sequentially number the files create, set up your printer output parameters in SnagIt beforehand (this is not essential).

  1. Open the PDF. You don’t need full Acrobat for this — Adobe Reader is fine.
  2. Select File > Print from the menu.
  3. Select the SnagIt printer drive from the list of printers on the Print dialog.
  4. Select the page range (it’s All by default).
  5. Click OK.
  6. An image of each page is captured according to your SnagIt printer defaults (if you set them), and the images are sent to SnagIt Editor, where you can modify them or save them as something else.
  7. Open the Word document and insert the images into the document as you normally would. If the images are large (as Carol’s were), add an A3 landscape section for the images.

Other options

Some other options for getting a PDF into Word include:

  • Wait until your Word document is PDF’ed, then add the pages of the existing PDF into it using Document > Insert Pages from the Acrobat menu.
  • Copy and paste the Excel table directly into Word — see https://cybertext.wordpress.com/2009/06/05/word-2003-import-an-excel-2003-table/
  • Select the text in the PDF, then copy/paste it into Word, OR save the PDF as a *.txt or *.rtf or *.doc file. Note: With any of these methods, you’ll lose some or all formatting, so only do this if the PDF is small and uncomplicated.
  • Insert the PDF as an object (linked or not) with an icon. However, it won’t print out the text when you print the Word document — you have to double-click the PDF icon first to open the PDF, print it out separately, then print the Word document.

See also:

Related:

[Links last checked August 2011]

h1

Print a file poster size

August 5, 2011

Did you know that most modern printers allow you to print a photo or other file in poster size? Assuming you don’t have a large plot/plan printer or an A3 paper drawer, you can still do this on your ordinary printer — you’ll just have to tape or glue the resulting printouts together (memories of desktop publishing on an electric typewriter!).

Somewhere in your printer’s properties you should find a setting like the one below (of course, each printer’s properties are different, and a very cheap printer may not have this capability at all, so there are no guarantees that you can do this on YOUR printer):

The 3×3 option shown above would give you a printout that’s three pages tall and three pages wide — a total of nine printed pages. Before printing something this size, lay out nine pieces of your standard printer paper in a 3×3 grid to see if that’s what you really want — it’s pretty big, so you might want to try 2×2 instead.

h1

It’s not the only problem they have

August 4, 2011

I received an email at work yesterday regarding disruptions to Perth’s rail system.

Well, from the look of the email the trains weren’t the only thing not working for Transperth — the file links (highlighted in yellow in the screen shot below) in the email aren’t working either!

My guess is that these missing ‘filenames’ point to locations on an internal–not public–server.

Never a good idea…

h1

Outlook: Reusable text snippets

August 3, 2011

(I have adapted this post from an article in Words, available from: http://www.abelard.com.au/words-3-3.pdf)

You’re probably aware that you can set up several signatures in Outlook, and set one as the default. At any time, you can choose another signature  and use that instead of your default by inserting it from Insert > Signature (Outlook 2003 and later).

But did you know that you can also set up *any* text, save it, then insert it into any email? This is very handy for paragraphs you use often. Some uses I thought of straight away included: directions and map links to your home or business address, electronic banking details for people who need to pay you, multiple contact details such as Skype, Twitter, Facebook, etc., as well as ‘boilerplate’ text that you might use in response to a sales/service inquiry. The possibilities are endless…

There are two sets of steps:

  1. Create a snippet.
  2. Insert the snippet into an email.

Step 1: Create the snippet

  1. Open Outlook.
  2. Click New to start a new email message.
  3. In the subject line, enter something that describes this snippet (e.g. ‘directions to house’, ‘electronic banking details’, etc.)
  4. In the message body, write the text.
  5. Save the email. By default, your email message is saved in your Drafts folder — once saved, you can move it to any other folder (e.g. if you have a lot of snippets or a lot of other drafts, you might want to create a special Snippets folder).

Step 2: Insert the snippet into an email

You’re part way through writing your email and you want to add a saved text snippet:

  1. Find the snippet:
    • Word 2003: On the Insert menu, select Item.
    • Word 2007: On the Insert tab, select Attach Item.
    • Word 2010: On the Insert tab, select Outlook Item.
  2. On the top panel of the Insert Item window, select the folder where you store your snippets (Drafts is the default folder for saved email messages).
  3. In the lower panel, select the name of the snippet.
  4. Select the Text only option under Insert as, then click OK.

    Outlook's Insert Item window

    Outlook's Insert Item window

  5. The subject line and the message are inserted into your current email — you just need to delete the subject line.
  6. Once in your current email, you can alter the text snippet — the original won’t change.

[Links last checked August 2011]

h1

Specialist dictionaries etc.

August 2, 2011

I’ve written before about some specialized online dictionaries (in the See also links below), but a recent newsletter from Chuck Green at ideabook.com listed some I wasn’t aware of and that looked useful under certain circumstances. They included:

And here’s another one from me too, for all the Scrabble fans: http://wordsolver.net

See also:

[Links last checked August 2011]