Find/Replace macro

M

MD

I must translate all files in web (there is about 40 words).
Please if someone can write me a sample macro source for one word.
 
J

Jim Cheshire

MD,

You can use FrontPage's replace functionality for something this simple and
it should work quite well.

--
Jim Cheshire
Jimco Add-ins
http://www.jimcoaddins.com
===================================
Co-author of Special Edition
Using Microsoft FrontPage 2003
 
J

Jim Cheshire

If you run a macro, it's going to be the same as running the replace
function. The difference is that you have to spend quite a bit of time
writing and debugging the code in a macro, and the Replace function is
already written!

--
Jim Cheshire
Jimco Add-ins
http://www.jimcoaddins.com
===================================
Co-author of Special Edition
Using Microsoft FrontPage 2003
 
M

MD

It is not the same because in macro I can define words that must be replaced
and I don't need to type it every time I want to replace it.
 
J

Jim Cheshire

That's a VERY small amount of work in comparison to the large amount of work
involved in writing and debugging a macro to do this.

--
Jim Cheshire
Jimco Add-ins
http://www.jimcoaddins.com
===================================
Co-author of Special Edition
Using Microsoft FrontPage 2003
 
M

MD WebsUnlimited.com

Hmm, this is a programming NG so if MD wishes to spend a large amount of
work to accomplish this then ......
 
M

MD WebsUnlimited.com

Hi MD,

The simplest form is to use the following:

Dim sDoc as string

sDoc = ActiveDocument.documentHTML
'
' then use the VB verb replace as required
'
sDoc = Replace(sDoc,"mywords","yourwords")

ActiveDocment.documentHTML = sDoc.

Note documentHTML, to the best of my recollection, is not available under FP
2000.

..If you require an example that will iterates over the files with in a web
replacing multiple values please let me know
 
J

Jim Cheshire

Be very careful when running this type of code. It has a chance of
destroying content and cannot be undone. You should be EXTREMELY careful
when writing code that does global changes to your code. Test it very
carefully on a copy of your Web site first to be sure that it doesn't do
something unwanted to your site.

--
Jim Cheshire
Jimco Add-ins
http://www.jimcoaddins.com
===================================
Co-author of Special Edition
Using Microsoft FrontPage 2003
 
J

Jim Cheshire

I think you didn't read his post. He asked for someone to write it for him.

As a programmer, if you're going to add value, I think you need to be sure
to let people know the pitfalls of their desired implementation. Providing
code to someone that removes code from the Web site globally when it hasn't
been carefully tested and debugged is irresponsible. That was my point.

--
Jim Cheshire
Jimco Add-ins
http://www.jimcoaddins.com
===================================
Co-author of Special Edition
Using Microsoft FrontPage 2003
 
M

MD

I tried to run this macro but it gives me an error.

Sub Translate()
Dim sDoc As String
sDoc = ActiveDocument.DocumentHTML
'
' then use the VB verb replace as required
'
sDoc = Replace(sDoc, "Round", "Kolo")
ActiveDocment.DocumentHTML = sDoc -----> Runtime error 424 Object Required
End Sub

Sorry its may be trivial but I am not a programmer.
This script is for replacing one word. How I can replace more words?
Can I do it like this?

:
Sub Translate()
Dim sDoc As String
Dim sDoc2 As String

sDoc = ActiveDocument.DocumentHTML
'
' then use the VB verb replace as required
'
sDoc = Replace(sDoc, "Word1", "Word1_1")
ActiveDocment.DocumentHTML = sDoc


sDoc2 = ActiveDocument.DocumentHTML
'
' then use the VB verb replace as required
'
sDoc2 = Replace(sDoc2, "Word2", "Word2_2")
ActiveDocment.DocumentHTML = sDoc

..
..
..
..
..


End Sub


Thank you
Tihomir Borovcak
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top