Genius123
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.Inse rtBefore Trim(rst("BEZ"))
But instead of pulling in "asdf", it pulls over this:
{\rtf1\ansi\ansicpg1252\de ff0\deflan g1033{\fon ttbl{\f0\f nil\fchars et0 Times New Roman;}}
{\colortbl ;\red0\green0\blue0;}
{\*\generator Msftedit 5.41.21.2510;}\viewkind4\u c1\pard\tx 640\tx1280 \tx1920\tx 2560\tx320 0\tx3840\t x4480\tx51 20\tx5760\ tx6400\tx7 040\tx7680 \tx8320\tx 8960\tx960 0\tx10240\ tx10880\tx 11520\tx12 160\tx1280 0\tx13440\ tx14080\tx 14720\tx15 360\tx1600 0\tx16640\ tx17280\tx 17920\tx18 560\tx1920 0\tx19840\ tx20480\cf 1\f0\fs20 asdf\par
}
Thanks for your help,
Joel
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("
oADOConn, adOpenKeyset, adCmdTable
objDoc.Bookmarks("Notes").
But instead of pulling in "asdf", it pulls over this:
{\rtf1\ansi\ansicpg1252\de
{\colortbl ;\red0\green0\blue0;}
{\*\generator Msftedit 5.41.21.2510;}\viewkind4\u
}
Thanks for your help,
Joel
ASKER
Nothing changed.... Maybe there is some function like this?...
e.g. objDoc.Bookmarks("Notes"). Range.Inse rtBefore FormatFromRichTextToPlainT ext(rst("BEZ")
e.g. objDoc.Bookmarks("Notes").
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@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
only methods i have seen use MSWord as the convertor. given you have a reference to oDoc already this may be of use... stackoverflow
ASKER
That worked, thanks.
objDoc.Bookmarks("Notes").
Chris