creating html from shape text

J

Jacco

Hi All,
I am using the writeline function to write some HTML to a file. The
text comes from a number of shapes on the page. This all works fine as
long as the text in the shapes does not contain any special
characters. Some characters in the text make the writeline function
generate an error (Run-time error '5', Invalid procedure call or
argument). I am now looking for a way to determine which characters
are causing this 'bad argument' error.

Does anyone know of a list of illegal characters, and how to eliminate
them, or convert them to legal characters? I have for instance
determined that a 'soft return' (shift enter when entering text) gives
a problem. However, I cannot find this character when exporting the
text. When I do a print.debug of the text, the character shows up as a
'?'. But, when I use the Asc() funtion to determine the character, it
gives me the value 63. Which is in fact the ascii value of the '?'. A
normal '?' does not generate the same error.

In the end, I want to convert all special characters (quotes, <, >,
etc) to their HTML counterparts. If anyone knows of a function that
can do that, I'd be very interested.

Hope this makes some sense, and someone has an idea!

Jacco

Oh, PS: I am using Visio 2003.
 
J

John Goldsmith

Hello Jacco,

I'm afraid I haven't got a full answer for you but have you tried saving the
files in xml format and examining the offending text there? Checkout these
two links (albeit for 2002 but they might help):

http://msdn2.microsoft.com/en-us/library/aa218413(office.10).aspx

http://msdn2.microsoft.com/en-us/library/aa218415(office.10).aspx

For your HTML conversion, you might find some of the HTML escape functions
interesting within the Save As Web output (only as a guide really).

Save a Visio doc as a web page and then check out the HTMLEscape / Unescape
javascript functions at the bottom of the frameset.js file.

Hope that helps.

Best regards

John


John Goldsmith
www.visualSignals.typepad.co.uk
www.visualSignals.co.uk
 
C

Chris Roth [MVP]

Hi Jacco,

A quick note about Visio text on shapes:

If your shape-text has an inserted field that displays data about the shape
in the text, then you'll get those pesky "?" characters. For instance, I
made a 2.25 inch-wide shape, and inserted the "Width" field into the text. I
then used the following automation in the VBA Immediate window:

? visio.ActiveWindow.Selection(1).Text
?

(? was the result)

I then changed the code to shape.Characters.Text:

?visio.ActiveWindow.Selection(1).Characters.Text
2.25

And got the right result. So use shp.Characters.Text. This will work just
fine even if the text isn't a field, and is just plain-old typed-in text.


--
Hope this helps,

Chris Roth
Visio MVP

Free Visio shapes:
http://www.visguy.com/category/shapes
Visio programming info:
http://www.visguy.com/category/programming/
Other Visio resources:
http://www.visguy.com/visio-links/
 
J

Jacco

Cheers for your help both! I have played around with the Characters
option, but in the end found another solution to the problem. It
turned out that the offending character was one of an extended
character set. Instead of using the Asc() function, I tried the AscW()
function to determine the value of the offending character. Instead of
63, I now got a value of 8232! SO, after finding that out, I have
inserted a Replace() function ( cLine = Replace(cLine, ChrW(8232),
"<br>" ), and this has solved my problem for now. I'm sure I'll run
into other special characters as well, but I now have an idea how to
possibly solve those too.

Thanks again,

Jacco
 

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