Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
conditional macro
I have saved thousands of pages in hundreds of folders. (PhD).
have used Calibri 8 and Calibri 10. I now have to change the Calibri 8 to Calibri 10 and the Calibri 10 to calibri 12. I have used this (see below) and few other varients of this macro, but to no avail. may somebody please suggest a solution. many thanks EW p.s. "Find / replace" will not work as their are 1000's of pages. Sub A() ' Selection.WholeStory With Selection.Font If ActiveDocument.Range.Font.Size = 10 Then ActiveDocument.Range.Font.Size = 12 Else If ActiveDocument.Range.Font.Size = 8 Then ActiveDocument.Range.Font.Size = 10 End If End If End With ActiveDocument.Save End Sub |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
conditional macro
If all of the paragraphs use just one font size, then you could use
Dim i As Long With ActiveDocument For i = 1 To .Paragraphs.Count .Paragraphs(i).Range.Font.Size = .Paragraphs(i).Range.Font.Size + 2 Next i End With However, if you have different font sizes within paragraphs, you would have to do it on a Word by Word basis using Dim i As Long With ActiveDocument For i = 1 To .Words.Count .Words(i).Font.Size = .Words(i).Font.Size + 2 Next i End With If you moved all of the files into one folder, you could incorporate the relevant of the above pieces of code into a modification of the code in the article "Find & ReplaceAll on a batch of documents in the same folder" at: http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm to process all of the documents in one go. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Eran" wrote in message ... I have saved thousands of pages in hundreds of folders. (PhD). have used Calibri 8 and Calibri 10. I now have to change the Calibri 8 to Calibri 10 and the Calibri 10 to calibri 12. I have used this (see below) and few other varients of this macro, but to no avail. may somebody please suggest a solution. many thanks EW p.s. "Find / replace" will not work as their are 1000's of pages. Sub A() ' Selection.WholeStory With Selection.Font If ActiveDocument.Range.Font.Size = 10 Then ActiveDocument.Range.Font.Size = 12 Else If ActiveDocument.Range.Font.Size = 8 Then ActiveDocument.Range.Font.Size = 10 End If End If End With ActiveDocument.Save End Sub |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
conditional macro
I would test this on COPIES of your files, but maybe something like
Sub ChangeFontSize() Dim rFont As Range Dim vOldSize As Variant Dim vNewSize As Variant Dim i As Long vOldSize = Array(10, 8, 10.5, 12.5) vNewSize = Array(12.5, 10.5, 10, 12) For i = 0 To UBound(vOldSize) Selection.HomeKey wdStory With Selection.Find .Font.Size = vOldSize(i) Do While .Execute(Forward:=True) = True Set rFont = Selection.Range rFont.Font.Size = vNewSize(i) Selection.Collapse wdCollapseEnd Loop End With Next i End Sub If you wish to batch process a while folder full of documents then Sub ChangeFontSize() Dim strFile As String Dim strPath As String Dim oDoc As Document Dim rFont As Range Dim vOldSize As Variant Dim vNewSize As Variant Dim i As Long Dim fDialog As FileDialog vOldSize = Array(10, 8, 10.5, 12.5) vNewSize = Array(12.5, 10.5, 10, 12) Set fDialog = Application.FileDialog(msoFileDialogFolderPicker) With fDialog .Title = "Select Folder containing the documents to be modifed and click" OK "" .AllowMultiSelect = False .InitialView = msoFileDialogViewList If .Show -1 Then MsgBox "Cancelled By User" Exit Sub End If strPath = fDialog.SelectedItems.Item(1) If Right(strPath, 1) "\" Then strPath = strPath + "\" End With If Documents.Count 0 Then Documents.Close SaveChanges:=wdPromptToSaveChanges End If strFile = Dir$(strPath & "*.do?") While strFile "" Set oDoc = Documents.Open(strPath & strFile) For i = 0 To UBound(vOldSize) Selection.HomeKey wdStory With Selection.Find .Font.Size = vOldSize(i) Do While .Execute(Forward:=True) = True Set rFont = Selection.Range rFont.Font.Size = vNewSize(i) Selection.Collapse wdCollapseEnd Loop End With Next i oDoc.Close SaveChanges:=wdSaveChanges strFile = Dir$() Wend End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Eran wrote: I have saved thousands of pages in hundreds of folders. (PhD). have used Calibri 8 and Calibri 10. I now have to change the Calibri 8 to Calibri 10 and the Calibri 10 to calibri 12. I have used this (see below) and few other varients of this macro, but to no avail. may somebody please suggest a solution. many thanks EW p.s. "Find / replace" will not work as their are 1000's of pages. Sub A() ' Selection.WholeStory With Selection.Font If ActiveDocument.Range.Font.Size = 10 Then ActiveDocument.Range.Font.Size = 12 Else If ActiveDocument.Range.Font.Size = 8 Then ActiveDocument.Range.Font.Size = 10 End If End If End With ActiveDocument.Save End Sub |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
conditional macro
Hi Doug
Would this work with percentages? i.e.:- .Paragraphs(i).Range.Font.Size = .Paragraphs(i).Range.Font.Size + 5% or .Paragraphs(i).Range.Font.Size = .Paragraphs(i).Range.Font.Size 105% ??? Thanks Phil (trying to keep my colleagues happy with nice buttons) On 23 Jan, 06:48, "Doug Robbins - Word MVP" wrote: If all of the paragraphs use just one font size, then you could use Dim i As Long With ActiveDocument * * For i = 1 To .Paragraphs.Count * * * * .Paragraphs(i).Range.Font.Size = .Paragraphs(i).Range.Font.Size + 2 * * Next i End With However, if you have different font sizes within paragraphs, you would have to do it on a Word by Word basis using Dim i As Long With ActiveDocument * * For i = 1 To .Words.Count * * * * .Words(i).Font.Size = .Words(i).Font.Size + 2 * * Next i End With If you moved all of the files into one folder, you could incorporate the relevant of the above pieces of code into a modification of the code in the article "Find & ReplaceAll on a batch of documents in the same folder" at: http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm to process all of the documents in one go. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Eran" wrote in message ... I have saved thousands of pages in hundreds of folders. (PhD). have used Calibri 8 and Calibri 10. I now have to change the Calibri 8 to Calibri 10 and the Calibri 10 to calibri 12. I have used this (see below) and few other varients of this macro, but to no avail. may somebody please suggest a solution. many thanks EW p.s. "Find / replace" will not work as their are 1000's of pages. Sub A() ' * *Selection.WholeStory * *With Selection.Font * * * * * *If ActiveDocument.Range.Font.Size = 10 Then * * * * * * * *ActiveDocument.Range.Font.Size = 12 * * * * * * * *Else * * * * * * If ActiveDocument.Range.Font.Size = 8 Then * * * * * * * *ActiveDocument.Range.Font.Size = 10 End If End If End With ActiveDocument.Save End Sub |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
conditional macro
Use
.Paragraphs(i).Range.Font.Size = .Paragraphs(i).Range.Font.Size * 1.05 -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com wrote in message ... Hi Doug Would this work with percentages? i.e.:- .Paragraphs(i).Range.Font.Size = .Paragraphs(i).Range.Font.Size + 5% or .Paragraphs(i).Range.Font.Size = .Paragraphs(i).Range.Font.Size 105% ??? Thanks Phil (trying to keep my colleagues happy with nice buttons) On 23 Jan, 06:48, "Doug Robbins - Word MVP" wrote: If all of the paragraphs use just one font size, then you could use Dim i As Long With ActiveDocument For i = 1 To .Paragraphs.Count .Paragraphs(i).Range.Font.Size = .Paragraphs(i).Range.Font.Size + 2 Next i End With However, if you have different font sizes within paragraphs, you would have to do it on a Word by Word basis using Dim i As Long With ActiveDocument For i = 1 To .Words.Count .Words(i).Font.Size = .Words(i).Font.Size + 2 Next i End With If you moved all of the files into one folder, you could incorporate the relevant of the above pieces of code into a modification of the code in the article "Find & ReplaceAll on a batch of documents in the same folder" at: http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm to process all of the documents in one go. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Eran" wrote in message ... I have saved thousands of pages in hundreds of folders. (PhD). have used Calibri 8 and Calibri 10. I now have to change the Calibri 8 to Calibri 10 and the Calibri 10 to calibri 12. I have used this (see below) and few other varients of this macro, but to no avail. may somebody please suggest a solution. many thanks EW p.s. "Find / replace" will not work as their are 1000's of pages. Sub A() ' Selection.WholeStory With Selection.Font If ActiveDocument.Range.Font.Size = 10 Then ActiveDocument.Range.Font.Size = 12 Else If ActiveDocument.Range.Font.Size = 8 Then ActiveDocument.Range.Font.Size = 10 End If End If End With ActiveDocument.Save End Sub |
#6
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
conditional macro
Use
.Paragraphs(i).Range.Font.Size = .Paragraphs(i).Range.Font.Size * 1.05 -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com wrote in message ... Hi Doug Would this work with percentages? i.e.:- .Paragraphs(i).Range.Font.Size = .Paragraphs(i).Range.Font.Size + 5% or .Paragraphs(i).Range.Font.Size = .Paragraphs(i).Range.Font.Size 105% ??? Thanks Phil (trying to keep my colleagues happy with nice buttons) On 23 Jan, 06:48, "Doug Robbins - Word MVP" wrote: If all of the paragraphs use just one font size, then you could use Dim i As Long With ActiveDocument For i = 1 To .Paragraphs.Count .Paragraphs(i).Range.Font.Size = .Paragraphs(i).Range.Font.Size + 2 Next i End With However, if you have different font sizes within paragraphs, you would have to do it on a Word by Word basis using Dim i As Long With ActiveDocument For i = 1 To .Words.Count .Words(i).Font.Size = .Words(i).Font.Size + 2 Next i End With If you moved all of the files into one folder, you could incorporate the relevant of the above pieces of code into a modification of the code in the article "Find & ReplaceAll on a batch of documents in the same folder" at: http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm to process all of the documents in one go. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Eran" wrote in message ... I have saved thousands of pages in hundreds of folders. (PhD). have used Calibri 8 and Calibri 10. I now have to change the Calibri 8 to Calibri 10 and the Calibri 10 to calibri 12. I have used this (see below) and few other varients of this macro, but to no avail. may somebody please suggest a solution. many thanks EW p.s. "Find / replace" will not work as their are 1000's of pages. Sub A() ' Selection.WholeStory With Selection.Font If ActiveDocument.Range.Font.Size = 10 Then ActiveDocument.Range.Font.Size = 12 Else If ActiveDocument.Range.Font.Size = 8 Then ActiveDocument.Range.Font.Size = 10 End If End If End With ActiveDocument.Save End Sub |
#7
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
conditional macro
On 4 Mar, 08:09, "Doug Robbins - Word MVP on news.microsoft.com"
wrote: Use *.Paragraphs(i).Range.Font.Size = .Paragraphs(i).Range.Font.Size * 1.05 -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com wrote in message ... Hi Doug Would this work with percentages? i.e.:- * * *.Paragraphs(i).Range.Font.Size = .Paragraphs(i).Range.Font.Size + 5% or * * *.Paragraphs(i).Range.Font.Size = .Paragraphs(i).Range.Font.Size 105% ??? Thanks Phil (trying to keep my colleagues happy with nice buttons) On 23 Jan, 06:48, "Doug Robbins - Word MVP" wrote: If all of the paragraphs use just one font size, then you could use Dim i As Long With ActiveDocument For i = 1 To .Paragraphs.Count .Paragraphs(i).Range.Font.Size = .Paragraphs(i).Range.Font.Size + 2 Next i End With However, if you have different font sizes within paragraphs, you would have to do it on a Word by Word basis using Dim i As Long With ActiveDocument For i = 1 To .Words.Count .Words(i).Font.Size = .Words(i).Font.Size + 2 Next i End With If you moved all of the files into one folder, you could incorporate the relevant of the above pieces of code into a modification of the code in the article "Find & ReplaceAll on a batch of documents in the same folder" at: http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm to process all of the documents in one go. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Eran" wrote in message ... I have saved thousands of pages in hundreds of folders. (PhD). have used Calibri 8 and Calibri 10. I now have to change the Calibri 8 to Calibri 10 and the Calibri 10 to calibri 12. I have used this (see below) and few other varients of this macro, but to no avail. may somebody please suggest a solution. many thanks EW p.s. "Find / replace" will not work as their are 1000's of pages. Sub A() ' Selection.WholeStory With Selection.Font If ActiveDocument.Range.Font.Size = 10 Then ActiveDocument.Range.Font.Size = 12 Else If ActiveDocument.Range.Font.Size = 8 Then ActiveDocument.Range.Font.Size = 10 End If End If End With ActiveDocument.Save End Sub Thanks for that, most helpful. Phil |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Conditional Formating | Tables | |||
Spell Check a protected Form with a Macro & already have forms picture macro | Microsoft Word Help | |||
Pause an executing Word Macro to enter info and then Macro continu | Microsoft Word Help | |||
conditional footer | Microsoft Word Help | |||
Conditional Slash Similar to Conditional Hyphen? | Page Layout |