Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-13-2014, 04:07 AM
romanticbiro romanticbiro is offline replace letters by font without losing format Windows 7 32bit replace letters by font without losing format Office 2003
Advanced Beginner
replace letters by font without losing format
 
Join Date: Feb 2014
Posts: 42
romanticbiro is on a distinguished road
Default replace letters by font without losing format


hello dear members
kindly need your help in this senario
i've files need to change character by font name to another
and not loos style and format or change letter case.
so, need to make external file contain those paires of text, if possible, or at lest define this in code as lest like (! = A)
(1 = a)
example, if we have ! (times new roman font) replace to (A) tahoma font.
external table help me to add any text without change code everytime, but could we make this table in excel or word file, show only by password or something secured
many thanks for your help.


bero
Reply With Quote
  #2  
Old 02-13-2014, 12:05 PM
macropod's Avatar
macropod macropod is offline replace letters by font without losing format Windows 7 32bit replace letters by font without losing format Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi bero,

It really isn't clear what you're trying to do.

You mention changing fonts, but not formatting. That's hard to do and is often impossible, since the letter widths and heights in one font are rarely the same as in another font.

You also mention the use of a file with a table and the needs to process multiple documents. For a Word macro that uses an Excel workbook to hold Find/Replace expressions for use in multiple documents, see: https://www.msofficeforums.com/word-...html#post34254
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 02-13-2014, 03:09 PM
romanticbiro romanticbiro is offline replace letters by font without losing format Windows 7 32bit replace letters by font without losing format Office 2003
Advanced Beginner
replace letters by font without losing format
 
Join Date: Feb 2014
Posts: 42
romanticbiro is on a distinguished road
Default

hello dear

all i mean need to find a letter by a specific font and replace it by another letter and change its font name too,
without change letter case (capital/small) or font size or style (regular, italic..)
thanks
Reply With Quote
  #4  
Old 02-13-2014, 08:02 PM
macropod's Avatar
macropod macropod is offline replace letters by font without losing format Windows 7 32bit replace letters by font without losing format Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You can do that using Find/Replace, without the need for any vba. Simply specify the character & font to find and the character and font it should be replaced with.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 02-14-2014, 07:30 AM
romanticbiro romanticbiro is offline replace letters by font without losing format Windows 7 32bit replace letters by font without losing format Office 2003
Advanced Beginner
replace letters by font without losing format
 
Join Date: Feb 2014
Posts: 42
romanticbiro is on a distinguished road
Default

ok. i know i able to do this by find and replace without vba,
but i've about more than 100 character, and need to do this task in many files.
so pleasure if you can help me.
thanks
Reply With Quote
  #6  
Old 02-14-2014, 04:59 PM
macropod's Avatar
macropod macropod is offline replace letters by font without losing format Windows 7 32bit replace letters by font without losing format Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You could use code like the following, but, if you're updating whole paragraphs, you really should do so by changing the paragraph Style; even for individual characters, if they're not in the same font as the paragraph Style, you should redefine them using a character Style.
Code:
Sub UpdateDocuments()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, wdDoc As Document
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
  Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
  With wdDoc.Range.Find
    .ClearFormatting
    .Text = "[A-Za-z0-9]"
    .Font.Name = "Times New Roman"
    With .Replacement
      .ClearFormatting
      .Text = "^&"
      .Font.Name = "Tahoma"
    End With
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
  End With
  wdDoc.Close SaveChanges:=True
  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
The above code will change all letters and numbers in all documents in the selected folder from Times New Roman to Tahoma. Since you haven't indicated anything substantial about what characters you're replacing, I can't provide much more help than that for the Find string.

PS: Don't store the file containing the macro in the same folder as the files to be processed.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 02-15-2014, 03:54 AM
romanticbiro romanticbiro is offline replace letters by font without losing format Windows 7 32bit replace letters by font without losing format Office 2003
Advanced Beginner
replace letters by font without losing format
 
Join Date: Feb 2014
Posts: 42
romanticbiro is on a distinguished road
Default

but could i use such code with excel sheet which contains paires of text i want to find it and replace by another and change its font as the above code
thanks
Reply With Quote
  #8  
Old 02-15-2014, 01:45 PM
macropod's Avatar
macropod macropod is offline replace letters by font without losing format Windows 7 32bit replace letters by font without losing format Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Why would you want to use an Excel workbook, if all you're doing is changing the font? You would only need an Excel workbook if you're changing the actual characters or whole strings to something else. Even then, you don't necessarily need to use Excel or an external file; For changes that are always the same, it's possible to encode the Find & Replace strings into the actual code.

You need to say clearly what it is you're trying to achieve. So far, your posts have been quite inconsistent about that.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 02-15-2014, 02:47 PM
romanticbiro romanticbiro is offline replace letters by font without losing format Windows 7 32bit replace letters by font without losing format Office 2003
Advanced Beginner
replace letters by font without losing format
 
Join Date: Feb 2014
Posts: 42
romanticbiro is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Why would you want to use an Excel workbook, if all you're doing is changing the font? You would only need an Excel workbook if you're changing the actual characters or whole strings to something else. Even then, you don't necessarily need to use Excel or an external file; For changes that are always the same, it's possible to encode the Find & Replace strings into the actual code.

You need to say clearly what it is you're trying to achieve. So far, your posts have been quite inconsistent about that.
dear
yes sure i want to replace the character depend on font too
example: i've file most of its text writen by times-new-roman, all i need make excel sheet contain find text and its replacement
and change any character its font times-new-roman to tahoma as its replacement in excel
in breef font converting from text to another
wish i help to explain the task
Reply With Quote
  #10  
Old 02-15-2014, 03:02 PM
macropod's Avatar
macropod macropod is offline replace letters by font without losing format Windows 7 32bit replace letters by font without losing format Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by romanticbiro View Post
i want to replace the character depend on font too
example: i've file most of its text writen by times-new-roman, all i need make excel sheet contain find text and its replacement
and change any character its font times-new-roman to tahoma as its replacement in excel
in breef font converting from text to another
This doesn't make it any clearer, especially as to why you're so keen to involve Excel.

As I have already said, twice now, if all you're doing is changing the font for some (or all) characters from Times New Roman to Tahoma, you don't need anything more than the macro I posted in post #6. Indeed, if you're doing this for a whole document, simply change the Style definitions.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 02-17-2014, 03:05 PM
romanticbiro romanticbiro is offline replace letters by font without losing format Windows 7 32bit replace letters by font without losing format Office 2003
Advanced Beginner
replace letters by font without losing format
 
Join Date: Feb 2014
Posts: 42
romanticbiro is on a distinguished road
Default

dear Paul
can i upload document to show you what i want exactly?
just let me know how i add attach to this post.
Reply With Quote
  #12  
Old 02-17-2014, 03:07 PM
macropod's Avatar
macropod macropod is offline replace letters by font without losing format Windows 7 32bit replace letters by font without losing format Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You can attach a document to a post via the paperclip symbol on the 'Go Advanced' tab.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #13  
Old 02-20-2014, 11:18 AM
romanticbiro romanticbiro is offline replace letters by font without losing format Windows 7 32bit replace letters by font without losing format Office 2003
Advanced Beginner
replace letters by font without losing format
 
Join Date: Feb 2014
Posts: 42
romanticbiro is on a distinguished road
Default

dear Paul

attached sample file in word and table in excel
wish it possible to do this sanario
thanks for your care
Attached Files
File Type: doc sample.doc (23.5 KB, 7 views)
File Type: xls ReplaceList.xls (13.5 KB, 8 views)
Reply With Quote
  #14  
Old 02-21-2014, 12:12 AM
macropod's Avatar
macropod macropod is offline replace letters by font without losing format Windows 7 32bit replace letters by font without losing format Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

So, notwithstanding all that you've posted before, you don't want only to change the font - in some cases you want to change the letters to something else as well. In that case, you can use the macro in the link I posted in post #2 in this thread. All you need to add to the code is the specification for the fonts to find and replace. For example, by adding:
Code:
        .Font.Name = "Tahoma"
        .Replacement.Font.Name = "IndexBlack"
before:
.Text = Split(xlFList, "|")(I)
You also need to delete:
.MatchWholeWord = True
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #15  
Old 02-21-2014, 06:36 AM
romanticbiro romanticbiro is offline replace letters by font without losing format Windows 7 32bit replace letters by font without losing format Office 2003
Advanced Beginner
replace letters by font without losing format
 
Join Date: Feb 2014
Posts: 42
romanticbiro is on a distinguished road
Default

dear paul
many thanks, this what i need to do.
sorry for bad explnation.
please, may better if i put excel file beside the documents and set path to this folder and no need to choose it every time i use macro.

below the text i edited in your code:
i think we need to delete .clear formatting ?

With .Find
.Font.Name = "Tahoma"
' need to delete this line?, .ClearFormatting
.Replacement
.Font.Name = "IndexBlack"
' need to delete this line .ClearFormatting
' might use it later .MatchWholeWord = True
.MatchCase = True

many thanks
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to replace digits with letters Bananabean Word VBA 6 09-14-2013 09:28 PM
replace letters by font without losing format How to replace all font occurencies by another (e.g. Arial-->Courier) pstein Word 1 04-30-2013 05:58 AM
replace letters by font without losing format Find and Replace maintain format winningson Word 3 01-19-2013 05:38 AM
replace letters by font without losing format Format Font herbhh Word 10 05-23-2011 08:29 AM
How do I import text columns with specified spacing between words w/o losing format? Fucius Word 0 08-09-2010 06:23 PM

Other Forums: Access Forums

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


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