![]() |
|
#1
|
|||
|
|||
|
I have about a hundred documents that I am needing to replace stacked fractions (auto-formatted) with regular unstacked text like this " 1/4 " Is there a quick way of doing this to save me an hour of work? Thanks!
|
|
#2
|
||||
|
||||
|
The ¼, ½, & ¾ fractions are typically single characters, not the three separate characters you'd get with fractions like 1/3, 2/3, etc. Assuming what you have is the ¼, ½, & ¾ characters, you can simply use Find/Replace to replace ¼ with 1/4, ½ with 1/2, & ¾ with 3/4. For a macro you might use to process a folder full of document containing such fractions, try:
Code:
Sub BulkFindReplace()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, strDocNm As String, wdDoc As Document, i As Long
Dim FList, RList: FList = Array("¼", "½", "¾"): RList = Array("1/4", "1/2", "3/4")
'Get the folder to process
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
'Process each document in the folder
While strFile <> ""
If strFolder & "\" & strFile <> strDocNm Then
Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
'Process each word from the F/R List
With wdDoc
With .Range.Find
.ClearFormatting
.Replacement.ClearFormatting
.MatchWholeWord = True
.MatchCase = True
.Wrap = wdFindContinue
'Process each item in the Find/Replace Lists
'First dealing with numbers like 1?
For i = 0 To UBound(FList)
.Text = "([0-9])" & FList(i)
.Replacement.Text = "\1^s" & RList(i)
.Execute Replace:=wdReplaceAll
Next
'Then processing and remaining fraction charcters
For i = 0 To UBound(FList)
.Text = FList(i)
.Replacement.Text = RList(i)
.Execute Replace:=wdReplaceAll
Next
End With
'Close the document
.Close SaveChanges:=True
End With
End If
'Get the next document
strFile = Dir()
Wend
Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
For PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm For Mac macro installation & usage instructions, see: https://wordmvp.com/Mac/InstallMacro.html
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
Macropod, thank you so much. This is extremely helpful! The single character find/replace will probably be sufficient but you've got me curious about macros. Is this a macro that I build inside Word itself? I am new to the macro world and will have to do more research. I am using Word 2010. Anything that can speed up my efficiency is worth looking into. Thanks again.
EDIT: Just noticed the links you gave at the bottom. I'll make sure to give it a read. thanks |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Fractions Within Fractions
|
ALAN_VA | Word | 1 | 12-13-2016 10:00 AM |
| PowerPoint 2013 and Image Stacking | hamoneaster | PowerPoint | 2 | 09-06-2015 11:00 AM |
| Stacking charts and sending to front | Waterdude | Excel | 0 | 08-13-2015 03:27 PM |
| autocorrect for fractions | AusSoft | Word | 3 | 01-24-2010 06:55 PM |
Inserting Fractions
|
ali_c_uk | Excel | 1 | 11-29-2009 06:38 AM |