Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-06-2011, 02:06 AM
lordofscones lordofscones is offline Putting italics back into a document Windows 7 32bit Putting italics back into a document Office 2010 64bit
Novice
Putting italics back into a document
 
Join Date: Dec 2011
Posts: 5
lordofscones is on a distinguished road
Default Putting italics back into a document

A tricky one:

I have a document that I needed to remove all formatting, all hidden codes, headers, footers--everything--so it could be converted into an eBook.

Following their guide (Smashwords), I pasted the whole doc into notepad, then back into Word 2010 in a new file.

This is fine, except for one thing. I still need the italics, or the dialogue loses its emphasis.

So, is there any way to use the original document as a template to scan the new, unformatted one and only replace the italics? I thought about Compare Documents...but it didn't get me anywhere.

Any help appreciated.
Reply With Quote
  #2  
Old 12-06-2011, 02:38 AM
macropod's Avatar
macropod macropod is offline Putting italics back into a document Windows 7 64bit Putting italics back into a document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,342
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Hi lordofscones,

Pressing Ctrl-A then Ctrl-Shift-F9 should remove all fields (eg cross-reference fields, table of contents fields, etc), converting them to plain text.

You can use Find/Replace to delete bold, underline, etc formatting. What other kinds of formatting do you need to remove?
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 12-06-2011, 03:09 AM
lordofscones lordofscones is offline Putting italics back into a document Windows 7 32bit Putting italics back into a document Office 2010 64bit
Novice
Putting italics back into a document
 
Join Date: Dec 2011
Posts: 5
lordofscones is on a distinguished road
Default

That does work, but there are steps involved for each thing that needs to be cleaned up: individual formatting, images, bookmarks etc. I was hoping for a way to put the formatting that we want back in, ignoring all the rest, rather than the other way around.
I might be hoping for too much.
Thanks for that advice though. Much appreciated.
Reply With Quote
  #4  
Old 12-06-2011, 03:46 AM
macropod's Avatar
macropod macropod is offline Putting italics back into a document Windows 7 64bit Putting italics back into a document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,342
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Hi lordofscones,

Here's a macro to restore the italics. To use it, open both documents, activate the original document, add the macro to it, switch back to the document view, then run the macro (via Alt-F8).
Code:
Sub Reformat()
Dim Doc As Document, i As Long, j As Long
Set Doc = ActiveWindow.Next.Document
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Text = ""
    .Font.Italic = True
    With .Replacement
      .ClearFormatting
      .Text = ""
    End With
    .Forward = True
    .Wrap = wdFindStop
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute
  End With
  Do While .Find.Found
    i = .Start
    j = .End
    Doc.Range(i, j).Font.Italic = True
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
End Sub
Aside from the italics, is there any other formatting that should be preserved?
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #5  
Old 12-06-2011, 06:54 PM
lordofscones lordofscones is offline Putting italics back into a document Windows 7 32bit Putting italics back into a document Office 2010 64bit
Novice
Putting italics back into a document
 
Join Date: Dec 2011
Posts: 5
lordofscones is on a distinguished road
Default

Just italics is fine for now. I suppose I can always add other formatting if required down the road.

It does something...but not quite right. I seems to apply formatting at the character level, so a word may end up half italics if the positioning is not exact, or a word in the same place in the target document will get the italics, even though it is not italics in the source.

I guess the problem here is that the documents no longer match at the character level. In taking out all the formatting, there are not the same number of blank lines, no page/section breaks and so forth, so I imagine this will make it difficult to make them tally exactly.

Is there any way to do the same thing at a high level--with word-level matching? Do-able?

An alternative may be for the macro to ignore everything except alphanumerics? Perhaps that would remove the difference in formatting?

I do appreciate the help so far. Even that is enough to get me started. I'm even going to have a stab at modifying the macro myself with my ancient rudimentary programming skills...fingers crossed.
Reply With Quote
  #6  
Old 12-06-2011, 07:09 PM
lordofscones lordofscones is offline Putting italics back into a document Windows 7 32bit Putting italics back into a document Office 2010 64bit
Novice
Putting italics back into a document
 
Join Date: Dec 2011
Posts: 5
lordofscones is on a distinguished road
Default

A bit of testing reveals that the formatting in the target document is applied onto the same word, but for each paragraph into the document, the formatting slips one character forwards.

So in paragraph one, we get example
In para two, example
In para three, example
and so forth, until the formatting is being applied many many characters from where it is supposed to be.

Perhaps a problem with the looping or counters?
Reply With Quote
  #7  
Old 12-06-2011, 07:26 PM
macropod's Avatar
macropod macropod is offline Putting italics back into a document Windows 7 64bit Putting italics back into a document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,342
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Hi lordofscones,

That suggests the two documents have different layouts and the source document has some extra characters (eg extra 'empty' paragraphs for paragraph breaks). The macro assumes an identical layout.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #8  
Old 12-06-2011, 07:42 PM
lordofscones lordofscones is offline Putting italics back into a document Windows 7 32bit Putting italics back into a document Office 2010 64bit
Novice
Putting italics back into a document
 
Join Date: Dec 2011
Posts: 5
lordofscones is on a distinguished road
Default

Thanks, macropod.

Anyway to adjust the macro to skip all non-printing characters?
That would square the text up in both documents.
Reply With Quote
  #9  
Old 12-06-2011, 07:54 PM
macropod's Avatar
macropod macropod is offline Putting italics back into a document Windows 7 64bit Putting italics back into a document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,342
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

It'd be far easier if you simply copied the formatted source document to a new file, then used Format|Font|Regular on the whole of the target document before running the macro. If you need to clean up paragraph breaks in the target document, that's easily done too - by the addition of some code after the 'Loop' statement:
Code:
With Doc.Range
  With .Find
    .ClearFormatting
    .Text = "[^13]{2,}"
    .Replacement.Text = "^p"
    .MatchWildcards = True
    .Execute wdReplaceAll
  End With
End With
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Putting italics back into a document Italics and Fonts Mysteriously Vanish When a Word 2003 Document is Saved saclarkdoc Word 1 10-28-2011 03:56 PM
Putting italics back into a document Putting a bookmark on a REF field in the selection b0x4it Word VBA 4 05-26-2011 01:14 AM
How to retain italics when pasting from PDF? WaltR Word 0 03-01-2011 04:01 PM
Spellcheking, grammar and italics Rosseiro Word 0 08-20-2010 10:07 PM
Putting italics back into a document Putting a horizontal line in a Word Document -- should be simple, right? biotechguy Word 4 05-10-2010 11:58 AM

Other Forums: Access Forums - Senior Forums

All times are GMT -7. The time now is 09:51 AM.


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