PC Review


Reply
Thread Tools Rate Thread

Adding text from VBA macro to an HTML document

 
 
=?Utf-8?B?Z2dpdmF0aQ==?=
Guest
Posts: n/a
 
      21st Jun 2004
Hi,

I am trying to create a macro that will add a custom XML tag to an HTML document. the tag looks like this:
"<GEN:FieldValue Name="myName" />

When I tried using pasteHTML I get an error and I believe its because this is not a standard HTML phrase, so I am trying to use insertAdjacentText instead. this causes me two problems:

The first one is that it works every second time in an object saying that the object variable is not set. When I try to run it the second time it works but then it replaces every <,> and " with their HTML translations, i.e. < etc.

The code I'm using is as follows:


Sub AddHTML()

'Set up variables
Dim myTextRange As IHTMLTxtRange
Dim myHTML As String
Dim myDoc As FPHTMLDocument
Dim currentElement As IHTMLElement

Set myDoc = Application.ActiveDocument
If myDoc.ViewMode = 2 Then
myDoc.parseCodeChanges
End If

Set currentElement = myDoc.activeElement

currentElement.insertAdjacentText "afterBegin", "<GEN:FieldValue Name=""gil"" />"

End Sub

Any suggestions ?

Gil


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
open HTML document as text file Mark Microsoft Excel Programming 1 15th May 2008 04:28 AM
Adding Text to textbox from a html page Ashok Microsoft Dot NET Compact Framework 2 11th Dec 2006 10:50 AM
adding a macro file to a wor document =?Utf-8?B?QmVuIE5vYWxs?= Microsoft Word Document Management 1 29th Oct 2004 05:30 PM
Adding a macro to Excel (not to a document) Francesco Sblendorio Microsoft Excel Programming 2 24th May 2004 02:40 PM
adding text to the redered html source Microsoft ASP .NET 2 1st Dec 2003 07:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:54 AM.