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
With olInvite
> 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 text:="text"
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
blank).
End If
> Display
End With
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
outlook.
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
> news:B147F2F7-1BD8-44B8-A7C0-8E82E89E30BE@microsoft.com...
> > 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?
> .
>