Instructions for Typing the Document Insert the date that updates automatically and put it at the beginning of the document. ' The following parameters must be set as follows to find only text formatted for the specified font. Document Settings Set the margins for the document to 1.75' right and left, 1.5' top and bottom. Text = Clear all previously set formatting for Replace dialog box. ' Clear all previously set formatting for Find dialog box. on the Find menus magnifying glass and click Replace to automatically replace a.
If s.Words(1).Bold = True And s.Words(1).Characters(1) = "(" Then The best part about Microsoft Word is you can choose the default font. at the insertion point, insert a chart using the default settings. it works.) ' Do our bold heading replacements using find and replace, replace the documents text with Arial font to verdana font. (Some of the comments below were included on external resources I'd found, so whether they're actually necessary is questionable, but.
Unfortunately this doesn't seem to catch all of our cases, but it grabs most of them, and gets the user most of the way there. In particular, the text is within the first sentence of a paragraph. It is not recommended to make your page font dependent, because if the font is not already installed on your visitors computer (before they visit your site) it will not display in that font. Remou's answer is exactly what I needed, but since StackOverflow is a great resource, this is what I ended up tweaking it to for our particular case: The most commonly supported fonts are Verdana, Arial, Helvetica, Impact, Comic Sans MS, and a few others. Is there a way to find text with different formatting, in a Word macro? If I could normalize the space in the first case, then I could add the Font restrictions on my wildcard search to grab the correct content.Text = "Arial"īut, I'd need to be able to grab two differently formatted items in a search to normalize that space, which, from my limited knowledge of VBA, doesn't appear to be possible. Unfortunately, my wildcard search is going to find these instances too, unless I can restrict it by font styles. there's also cases where text is as follows:įor blocks like this, I want to completely skip the text. I thought a search for the below would work, without any format restrictions. While "(1)" and "Bold heading." have a consistent style (bold and Arial), the space between the two does not (it's Times New Roman, non-bold). With this text I'd like to perform a number of transformations upon the first part - (1) Bold heading. I'm working on creating a macro in Microsoft Word (2007) for a document that contains text such as this: