i want to create a font converter software that convert a font to another font in my regional language...
i have done all the hardwork...only one problem left that is
"i m not able edit it word by word"
plz help...
Printable View
i want to create a font converter software that convert a font to another font in my regional language...
i have done all the hardwork...only one problem left that is
"i m not able edit it word by word"
plz help...
If you want to loop through all the words in a document, use a for...each loop:
You canCode:For Each sWord in wdDoc.Range.Words
' Change the font for sWord
Next
Code:Dim sWord as Word.Range
i use the following code
Dim wrd As New Word.Application
Dim dc As Word.Document
Set dc = wrd.Documents.Open(pathtomyfile)
For i = 1 To Word.ActiveDocument.Paragraphs.Count
For Each w In Word.ActiveDocument.Paragraphs(i).Range.Words
s = w.Text
w.Text = convert_font(s)
w.Font.Name = myfont
Next w
next i
word.ActiveDocument.Save
here convert_font is a function that returns a string... i want the text of each word in the document is replaced with the value return by convert_font and then set the font name to my regional language font....
but it produce some wrong output in the document...
plz help... i have tried everything
if you want more help, post a sample document, to show original text and desired result, including code and function
vb Code:
For i = 1 To dc.Paragraphs.Count For Each w In dc.Paragraphs(i).Range.Words s = w.Text w.Text = convert_font(s) w.Font.Name = myfont Next w next i dc.Save
i had already used it...it just convert the first word of the document again and again and goes to infinite loop...
i m explaining here what i want to do...
i have a word document which contain some text e.g
abc defs asdrfhfs shdf dgfk
dfjdf fgdfg fdghddf
i want to convert the text in the document to look like..
dfs dfgf dfgffgfg gfgf fgfg
fgfgf fgfgg gfgfgffg
the conversion is to be done by the function convert_font that looks like..
Code:function convert_font( s as string) as string
'some database queries
' and set the convert_font to legal converted string
end function
it looks as if you are trying to make a simple translator
i am guessing because it makes no sence to pass a word to get it back unless it has changed
and I am guessing you language requires very different shaped characters
so...
selecting whole document and then change font
makes no sense to you
are changing the whole document to a single font
or
are you changing a number of fonts into several different fonts
here to talk
i would sort of guess that the font you want to change to is a unicode type font, and you may need to use strconv to convert the returned sting to a unicode string before the unicode font can work with it
thanks you solve my problem