-
Jan 3rd, 2012, 06:01 AM
#1
Thread Starter
New Member
[RESOLVED] editing word document 2003
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...
-
Jan 4th, 2012, 01:07 PM
#2
Addicted Member
Re: editing word document 2003
If you want to loop through all the words in a document, use a for...each loop:
Code:
For Each sWord in wdDoc.Range.Words
' Change the font for sWord
Next
You can
Code:
Dim sWord as Word.Range
Click "Rate This Post" if I helped you in any way.
The best process for finding help.
Step 1: Google it
Step 2: Google it again
Step 3: Google it yet again
Step 4: Ask on a forum
Step 5: Go to Step 1
-
Jan 5th, 2012, 04:59 AM
#3
Thread Starter
New Member
Re: editing word document 2003
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
-
Jan 5th, 2012, 05:50 AM
#4
Re: editing word document 2003
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
Last edited by westconn1; Jan 5th, 2012 at 05:56 AM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jan 9th, 2012, 05:24 AM
#5
Thread Starter
New Member
Re: editing word document 2003
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
-
Jan 9th, 2012, 06:39 AM
#6
Frenzied Member
Re: editing word document 2003
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
-
Jan 9th, 2012, 03:52 PM
#7
Re: editing word document 2003
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Feb 8th, 2012, 11:28 PM
#8
Thread Starter
New Member
Re: [RESOLVED] editing word document 2003
thanks you solve my problem
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|