Re: Help in programmatically setting formatting in an AppointmentI
I'm using Outlook 2007.
The code for the part where i'm using the WordEditor is something like this.
I havent used this before so I'm not sure what I'm doing wrong.
Dim wrdDoc as Word.Document
Dim wrdSel as Word.Selection 'etc etc
> Start = ' etc etc
If olInvite.GetInspector.EditorType = olEditorWord Then
Set wrdDoc = olInvite.GetInspector.WordEditor
Set wrdSel = wrdDoc.Windows(1).Selection
wrdSel.TypeText text:="text" ' i notice that if i try to change
something to bold in the middle of a line it doesnt work. but it works if the
text is on a new line.
wrdSel.Font.Bold = wdToggle
wrdSel.TypeText "some text"
wrdSel.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
wrdDoc.Hyperlinks.Add wrdSel.Range, "http://www.somelink.com" 'the
hyperlink with the "some text" seems to work only the first time (see below),
for all subsequent invites i get the hyperlink but no text displayed (just
Set wrdDoc = nothing
Set wrdSel = Nothing
set olInvite = nothing
Note: I got the code by recording a macro on MS Word and then modifying it.
By "first invite" i mean the invite that is generated when i use the macro
for the first time after i start outlook. all subsequent invites created by
using that macro partially lose the formatting, unless i actually restart
I hope you can help me out, i've never worked with VBA in such depth before.
"Sue Mosher [MVP]" wrote:
> More info, please: Outlook version, relevant code snippet, more explanation
> of what you mean by "the first invite."
> > Sue Mosher
> > >
> "Nilay" <Nilay> wrote in message
> > Hi,
> > i have created a macro to generate some meeting invites.
> > I used the WordEditor to set some formatting (Bold on/off, hyperlinks
> > etc).
> > However, i find that the formatting works only partially (or not at all).
> > so
> > far i've noticed that only the first invite generated is perfectly
> > formatted.
> > Can anyone help me out with this? Do i need to add something to the code
> > or
> > set some objects to null to ensure that the formatting stays throughout my
> > outlook session?