Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replacing text in an HTML file 1

Status
Not open for further replies.

KarenLloyd

Programmer
Nov 23, 2005
138
0
16
GB
Hi again

I want to use an HTML file as the body for emails to send via Outlook.

I was considering using Word to open the HTML file and insert a short message and signature, perhaps using a bookmark.

Sometimes Word can be slow to open, so this may not be ideal. Can anyone tell me if there is a quicker way to replace text into an HTML file please? For example, to replace '<Signature>' with 'Kind Regards - Me'

Thanks

Karen
 
Word is THE WORST POSSIBLE OPTION for editing HTML.

HTML is just text. If nothing else, read the file with FileToStr(), use StrTran() to do your substitution, and write the file back with StrToFile().

Dan
 
Ah - It's OK - dizzy spell over.

I can probably do this with STRTRAN() after using FILETOSTR() to get the contents.

I just need to remember to use the html formatting for &lt &gt and the carriage returns etc.
 
Hi Dan

You must have been replying while I was trying to re-engage my brain...

Think I've got it.

Thank you

Karen

 
The answer ALWAYS comes to me just as I've asked someone to help. :)

Glad you're on the right track!
 
Karen,
If you want a Fast HTML editor, do a search for DHTMLEDIT.OCX.
Microsoft built it into Internet Explorer but it is still available as a download.

I created a OleControl, Put the Control on a form and added buttons from all the simple HTML edit items like
Bold, Lists, Underline, Etc.

I then Created a Button Class that calls the form and it returns a HTML Formated String.

I have a application that creates a Data Schema for a 350+ Table Database and I use it to create the HTML files for the help document.

If you need help or want a copy of the Form, let me know.



David W. Grewe Dave
 
Hi Dave

I will certainly look at DHTMLEDIT.OCX

Thanks for the tip

Karen
 
Just for curiosity:

One simple and always available html editor is the IE or the Webbrowser Control. See what Riock Strahl does:

So you can do eg:
Code:
oIE = CreateObject("InternetExplorer.Application")
oIE.Navigate2("[URL unfurl="true"]http://tek-tips.com/")[/URL]
Do While oIE.ReadyState#4
   Doevents Force
EndDo 
oIE.Visible = .t.
oIE.Document.Designmode="on"

And instead of navigating to a webpage you can navigate to a file via a URL "file://...filename..." and you can save the changed HTML by saving oIE.Docuemnt.Body.innerHTML to a new file.

With Tek-Tips the site looks dearranged in desgnmode, that's beside other reasons, because you can see hidden fields of HTML forms. With simple basic HTML you'll rather see the page as it was before, only doubleclicking a text for example makes it editable.

Bye, Olaf.
 
Olaf,

I read the Rick Strahl article you mentioned, and struggled for quite a while with using the WebBrowser control as an embedded WYSIWYG HTML editor.

In the end, I had to give up, because there were so many things wrong with it: lots of little quirks, and things that didn't work properly (no reflection on Rick, of course).

I ended up with TinyMCE Editor from Moxiecode Systems ( This works extremely well. It's much more WYSIWYG, is easy to customise, and has an extensive set of toolbars. It's implemented in JavaScript, so you need to embed it in a web page, which you can then display in the WebBrowser control. (I haven't actually done that from within VFP, but I don't see why it shouldn't work.)

Karen: I don't think any of this is relevant to your own situation, because your concern is to modify the HTML programmatically, but it might be of interest to others.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Just to add a note to my previous post ....

If anyone is interested, you can see a couple of screen shots of the editors I mentioned, at:

The first shot is my attempt at a VFP form, with the WebBrowser control in edit mode, as per Rick's article. Note the small bit of Help text under the editing area to tell the user how to do bold, italic, etc. No toolbar here.

The second shot is the version that uses the Moxiecode editor. This has a proper toolbar - although I removed the vast majority of its many features for this simple form.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Hi Mike,

actually I've done that with TinyMCE. IT was a bit of fiddling with Javascript events to hook into eg Image choice dialogs and upload mechanism.

I actually would now want to redo that using the CKEditor ( and it's CKFinder, which I think is very nice and good for the image management.

For a little WYSIWYG editing of a HTML Mail template with a signature I think the IE designmode could be sufficient, though surely not ideal. Thinking of how seldom you need to setup or edit a signature, this would be fair to both developer and users.

Bye, Olaf.
 
Olaf,

That's interesting. In fact, I tried using CKEditor at the same time as TinyMCE.

It was a couple of years ago, but if I remember rightly, CKEditor is server-based (written in PHP, I think), whereas TinyMCE is entirely JavaScript, and therefore runs in the browser.

I got CKEditor running quite easily on my local system, but couldn't get it to work my from web hosting company's server - possibly because of PHP version differences. I didn't bother to trouble-shoot it; I just switched to TinyMCE instead.

They're both good products. I expect you could get CKEditor to work with a little effort. (And, by the way, I'm pleased they changed the name.)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Hi

I know the past few posts were not directed at me. I don't need to edit from within VFP at this stage.

But away from VFP, for editing HTML, PHP, etc, when I was doing coursework I used HTML-Kit for a while. (Just in case anyone new needs a simple editor.) That also has various toolbars for formatting and inserting tags etc

Karen
 
Karen, we have somewhat hijacked your thread with this discussion. But thanks for the pointer to HTML-Kit.

If I've understood it right, HTML-Kit is a stand-alone editor, unlike the tools that Olaf and I have been talking about, which are components for adding to an application.

But I'll make a note to look at HTML-Kit in more detail, as it does seem to offer a lot of features.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top