Help in programmatically setting formatting in an AppointmentItem

Status
Not open for further replies.
N

Nilay

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?
 
S

Sue Mosher [MVP]

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?
 
N

Nilay

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?


> .
>
 
S

Sue Mosher [MVP]

Re: Help in programmatically setting formatting in an AppointmentI

How formatting is applied depends in part on what the current Word.Selection

object encompasses. You should see similar effects when you're working

manually in a document. As you already seem to know a bit about how to move

the selection, I suggest you continue playing with that, using the Word

macro recorder as needed, to nail down the exact effect you want.

What do you mean by "partially lose formatting"?

I can't think of any reason why one meeting request created with the same

code would be any different from another.

Sue Mosher

"Nilay" <Nilay> wrote in message

news:4DC6BBC9-3417-4E76-B528-E43594FFC0C8@microsoft.com...
> 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 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?
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
F Microsoft Outlook Connector 14.0.6123.5001 - Help! Using Outlook 6
witzker Pls help to change the code for inserting date in Ol contact body Outlook VBA and Custom Forms 5
R Disable conversation thread from replying of recipients in the same subject. Please help Using Outlook 0
R seperate read layout to design in outlook 2016..Help!! Outlook VBA and Custom Forms 3
O Help .. got lost ... installing Office like 2016 Using Outlook 5
A Arthur needs help with 2007 Outlook e-mail Using Outlook.com accounts in Outlook 3
R Help Revising VBA macro to delete email over different time span Outlook VBA and Custom Forms 0
Marc2019 Need help please! Cannot Setup my outlook email account on my Mac Outlook 2011 Using Outlook.com accounts in Outlook 2
L Attachment saving and tracking - PLEASE help! Outlook VBA and Custom Forms 5
I Help with dates in task list. Using Outlook 5
C need help setting up outlook first time Using Outlook 1
K To do bar help Using Outlook 8
M Help sending email but removing signature via VBA Outlook VBA and Custom Forms 5
S help with outlook scripting Outlook VBA and Custom Forms 4
J Help Please!!! Outlook 2016 - VBA Macro for replying with attachment in meeting invite Outlook VBA and Custom Forms 9
EmelineGueguen Help to understand the problem of work Using Outlook 1
N Outlook Forms Help Outlook VBA and Custom Forms 2
N Need help syncing contacts to iPhone X Using Outlook 8
S VBA Macro - Run-time error '424': object required - Help Please Outlook VBA and Custom Forms 3
broadbander Needing help with reply/reply all while keeping attachments and adding a new CC recipient. Outlook VBA and Custom Forms 5
J Help! My contacts have disappeared. Using Outlook 5
J HELP- Rule to auto strip prepend from external emails Using Outlook 0
J Help Needed With Multi-Step Login Email Address Using Outlook.com accounts in Outlook 1
G Bcc help - Preventing multiple forwards from a bcc'd distribution group Using Outlook 1
G [Help] Converting array to destination folder path Outlook VBA and Custom Forms 1
K Help.... Office Outlook 2016 Using Outlook 1
S Error using AddressEntry.GetContact - need help Outlook VBA and Custom Forms 2
D Help with code to move mail on receipt to another folder based on time received Outlook VBA and Custom Forms 2
EaglePI Outlook 2010 need help with rules Using Outlook 0
B HELP! Using Outlook 4
Jeff Davis Help fix my Outlook 2013? Using Outlook 28
M Winmail. dat - HELP Using Outlook 2
Diane Poremsky Help! My Contacts are being updated! New Slipstick.com Articles 0
B VBA Help Email that will save as draft and send as attachment Outlook VBA and Custom Forms 3
J Can Anyone Help?? Outlook VBA and Custom Forms 1
C Newbie needs help with Outlook Macro Outlook VBA and Custom Forms 3
B Need Help - Willing to pay Outlook VBA and Custom Forms 10
D help with Item/Inspector close event Outlook VBA and Custom Forms 1
G Looking for help with our Organization Forms Library Outlook VBA and Custom Forms 1
J Need Help with Contacts VBA Outlook VBA and Custom Forms 1
L Outlook 2002: HTML Emails Will Not Print: Please Help Using Outlook 0
H Need help setting up GetFolderPath-Makro with Vodafone IMAP Mail-Account Outlook VBA and Custom Forms 0
A newb outlook macro help Outlook VBA and Custom Forms 1
T Need help with finding/updating task Outlook VBA and Custom Forms 1
X Help with custom form which is very similar to Tasks Outlook VBA and Custom Forms 6
joflo copy contents from outlook to excell - please help. Using Outlook 4
P Outlook 2010: Missing tab - "Format/Picture Tools" HELP! Using Outlook 3
L Looking for help - want to try an alternative to Outlook? Outlook Wishlist 0
M Help! Can't set up IMAP for gmail Using Outlook 2
A Help with VBA please! Outlook VBA and Custom Forms 15

Similar threads

Top