Avatar of Genius123
Genius123
Flag for United States of America asked on

VB Script in Outlook 2010

Hello,

From my custom Outlook form, I have a script that pulls the data from a SQL field that was just a text field to a Bookmark field in a Word doc.  It's worked fine.  

Now the definition of that same field in SQL was changed so that it could contain formatting information.  When I pull the data now, it pulls all the formatting garbage with it.  How can I just pull in the text that I want to see?  It can be plain text, or with the formatting, I don't care.

My code goes like this:

          rst.Open "Select BEZ FROM BW_AUFTR_KTXT WHERE TEXT_ID = 25 and ID = '" & Trim(Item.UserProperties("JobNumber").Value) & "'", _
          oADOConn, adOpenKeyset, adCmdTable

objDoc.Bookmarks("Notes").Range.InsertBefore Trim(rst("BEZ"))

But instead of pulling in "asdf", it pulls over this:

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}}
{\colortbl ;\red0\green0\blue0;}
{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\tx640\tx1280\tx1920\tx2560\tx3200\tx3840\tx4480\tx5120\tx5760\tx6400\tx7040\tx7680\tx8320\tx8960\tx9600\tx10240\tx10880\tx11520\tx12160\tx12800\tx13440\tx14080\tx14720\tx15360\tx16000\tx16640\tx17280\tx17920\tx18560\tx19200\tx19840\tx20480\cf1\f0\fs20 asdf\par
}


Thanks for your help,
Joel
VB ScriptMicrosoft WordMicrosoft Office

Avatar of undefined
Last Comment
Genius123

8/22/2022 - Mon
Chris Bottomley

What happens if you try the value property i.e.

objDoc.Bookmarks("Notes").Range.InsertBefore Trim(rst("BEZ").value)

Chris
Genius123

ASKER
Nothing changed....  Maybe there is some function like this?...


e.g.   objDoc.Bookmarks("Notes").Range.InsertBefore FormatFromRichTextToPlainText(rst("BEZ")
ASKER CERTIFIED SOLUTION
Rgonzo1971

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Robberbaron (robr)

@rgonzo.  just tested that out of interest and it does not work for richtext....

only methods i have seen use MSWord as the convertor. given you have a reference to oDoc already this may be of use... stackoverflow
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Genius123

ASKER
That worked, thanks.