Outlook 2007 Code for Note Fields of Appointment

Status
Not open for further replies.
In addition to changing the code so as I showed above, the macro that changes the font its perfect, but I don't see anyway to create a shortcut to it in the form of the calendar appointment....as I have to got thru the list of macros to find it and that's not easy as I have so many macros...so is there a way to create a button on the form of the calendar event to the macro? or is the shortcut like Ctrl + F to run the macro? Need get this done please!
 
You can customize the QAT to add a button for a macro. If you have a custom form, you can call the macro from a command_click macro.
 
In the Calendar Event form, I don't see a Quick Access Toolbar to add a macro to.....and don't understand what you said re call the macro from a command_click macro.....so how do I do it please?
 
Unless you are using a custom form, a control won't be much use.

Add the it to Quick Launch tool bar - click the triangle the arrow is pointing to, select Macros from the dropdown then location your macro. The default icon is that little boxy thing but you can modify it.

2007-macro.png
 
I actually found the QAT for my form I use and created the botton to the macro....so when the event is created, before I save it, I click on Ctrl +a and it selects all words in the body and then I run the macro....thank very much as usual....and now getting back to the more difficult area where we were trying the if lines...etc....that did not work....is there another way to do so those title words don't show up unless the value of the related field as words in it...the example is the Mobile Phone and if the related field in the contact does not have phone number, I don't want the name Mobile Phone to show up in the body of the calendar event.....
 
In addition, I have macros that change the font of selected words in the calendar body. So also, is there another way to have the calendar macro I posted, add in the font macro to the specific areas of the calendar macro to change the font of the words that are put in the calendar body??
 
To make this clear so there can be a couple of ways to get this done rightt away:

I have macros that change the font of the words I select in the body of the calendar event.

And below is an example of the code that does it.

So is the a seperate macro or codes to add to my code, that will autuomatically select specific words in the body of the calendar event so I click on them macro and it selects them, and then I click on the macro that changes the fonts.

Or is there a macro or codes to add to my code that will automtically select the lines of the body I want to select and then the font is changed to those lines.?

And finnally, in the Calendar click script code I posted earlier, can we select the words that come from the values of the fields that come with the title words? As then, I can use the code to change the fonts.

Would love to hear back as soon as possible. Public Sub FormatCalendarSelectedText_Black_Bold_14()
Dim objItem As Object
Dim objInsp As outlook.Inspector

' Add reference to Word library
' in VBA Editor, Tools, References
Dim objWord As Word.Application
Dim objDoc As Word.Document
Dim objSel As Word.Selection
On Error Resume Next


'Reference the current <span class="adtext" id="adtext_6">Outlook item</span
Set objItem = Application.ActiveInspector.currentItem
If Not objItem Is Nothing Then
If objItem.Class = olAppointment Then
Set objInsp = objItem.GetInspector
If objInsp.EditorType = olEditorWord Then
Set objDoc = objInsp.WordEditor
Set objWord = objDoc.Application
Set objSel = objWord.Selection

With objSel
' Formatting code goes here
.Font.Color = wdColorBlack
.Font.Size = 14
.Font.Bold = True
.Font.Underline = True
.Font.Name = "Times New Roman"
End With
End If
End If
End If

Set objItem = Nothing
Set objWord = Nothing
Set objSel = Nothing
Set objInsp = Nothing

End Sub
 
I figured out thru some places I read, the following is the code for Word documents, that goes to the specific line number....say line 4, and it automatically selects all words in the line. So is there a way to change this for Outlook so it does the same thing in the Body area the Calendar Event...as I have the codes to change the fonts to what is selected in the Body area of the Calendar Event. And if possible, can it select more than one line? Would love to do this right away. Sub Macro5()
Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute, Count:=4

Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend

End Sub
 
Now I have figured out in Microsoft Word, that the code identifies whatever llne numbers I decide and automatically changes the font I decided for the particular lines.....So the example below is as to Lines 1, 2, 4 and 5, as when I create a Calendar Event in Outlook 2007, it puts in the Body field of the Calendar Event, a list of words and even thought there are more, the beginning of the words are Lines 1,2, 4 abd 5. So below is the code for the Microsoft Word, and how do we make this work in Outlook 2007 for the Body field of a Calendar Event.

Sub SelectLine1_2_3_5()

Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute, Count:=1

Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Font.Name = "Times New Roman"
Selection.Font.Size = 14
Selection.Font.Color = -587137025
Selection.Font.Bold = True
Selection.Font.UnderlineColor = -587137025
Selection.Font.Underline = wdUnderlineSingle


Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute, Count:=2

Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Font.Name = "Times New Roman"
Selection.Font.Size = 14
Selection.Font.Color = -553582593
Selection.Font.Bold = True
Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute, Count:=4

Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Font.Name = "Times New Roman"
Selection.Font.Size = 14
Selection.Font.Color = -587137025
Selection.Font.Bold = True
Selection.Font.UnderlineColor = -587137025
Selection.Font.Underline = wdUnderlineSingle

Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute, Count:=5

Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Font.Name = "Times New Roman"
Selection.Font.Size = 14
Selection.Font.Color = -553582593
Selection.Font.Bold = True


End Sub
 
In addition, I just updgraded the code so it's clearer re color etc......but need to know how to put this in Outlook 2007

Sub SelectAllLines()

Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute, Count:=1

Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Font.Name = "Times New Roman"
Selection.Font.Size = 14
Selection.Font.Color = wdColorBlack
Selection.Font.Bold = True
Selection.Font.UnderlineColor = wdColorBlack
Selection.Font.Underline = wdUnderlineSingle


Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute, Count:=2

Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Font.Name = "Times New Roman"
Selection.Font.Size = 14
Selection.Font.Color = wdColorBlue
Selection.Font.Bold = True
Selection.Font.UnderlineColor = wdColorBlue
Selection.Font.Underline = wdUnderlineSingle
Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute, Count:=4

Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Font.Name = "Times New Roman"
Selection.Font.Size = 14
Selection.Font.Color = wdColorBlack
Selection.Font.Bold = True
Selection.Font.UnderlineColor = wdColorBlack
Selection.Font.Underline = wdUnderlineSingle

Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute, Count:=5

Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Font.Name = "Times New Roman"
Selection.Font.Size = 14
Selection.Font.Color = wdColorBlue
Selection.Font.Bold = True
Selection.Font.UnderlineColor = wdColorBlue
Selection.Font.Underline = wdUnderlineSingle
 
To The Smart Woman!!!;) I went back to what you said earlier using the "if" concept so if the field related to one of the titles does not have any value, the title does not show up....and I did it where there is no "End If" or "Else" and it does it perfectly!!!! But what we need to do other than the font area, is if there is no value and then no title word in the Calendar Event body field, there is still the spacing as if both the two lines of the If were showing up there and an third line space after...and this messes up the areas of the body it shows up....So below is an example of the four areas....and what do we change so if one does not show up since no related field value, there is no extra line spaces in the body in the order of the list of areas? if item.getinspector.modifiedformpages("General").controls("Phone4").text <> "" then txtMobile = "Mobile Number" & ":" & vbcrlf & item.getinspector.modifiedformpages("General").controls("Phone4").text & vbcrlf

if item.getinspector.modifiedformpages("General").controls("Phone1").text <> "" then txtBusiness = "Business Number" & ":" & vbcrlf & item.getinspector.modifiedformpages("General").controls("Phone1").text & vbcrlf
if item.getinspector.modifiedformpages("General").controls("ComboBox9").text <> "" then txtlaststatus = "Last Status" & ": " & vbcrlf & item.getinspector.modifiedformpages("General").controls("ComboBox9").text & vbcrlf

if item.getinspector.modifiedformpages("General").controls("TextBox22").text <> "" then txtlaststatusdate = "Last Status Date" & ": " & vbcrlf & item.getinspector.modifiedformpages("General").controls("TextBox22").text & vbcrlf
 
The line feed is in the if statement so you shouldn't get blank lines if the value is blank.

if item.getinspector.modifiedformpages("General").con trols("Phone4").text <> "" then txtMobile =

"Mobile Number" & ":" & vbcrlf & item.getinspector.modifiedformpages("General").con trols("Phone4").text & vbcrlf <<== this line shouldn't print if the condition (the field is not blank) and because the line feed is in it, you shouldn't get a line feed.
 
Thanks very much, but do I add something to it as it is created the space lines when field is blank......so do I add something?
 
Any way to fixt his please right away as well???
 
Can we fix this today re the space lines that are there as if there was the words but no words.....so is there something to add to each If line that takes care of this??
 
Everything looks fine to me, so I'm not sure what is going on. An if statement should work.
 
I have used exactly the code If code you gave me, and if there is not value in the say Phone4, it still adds the two lines as if there was a Phone Number in Phone4 plus the line space after the two lines per the body code so that if there were words, there is a line space between both top two lines an the next two lines......can we chance something in the If code or the body code, or add something that solves this?
 
To solve this area, I have created the following and I just need the simple codes for outlook that selects all words in the body field as if I did Ctrl + A, and a code as if I did Ctrl + C to copy all selected , and a code as if I did Ctrl + V to past all that was copied.

When I select all in the Outlook body, I run a word document that pastes to it what I selected and copied from the Outlook body, it takes care of fonts and the spaces, and it selectes and copies all adjusted words.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
L Outlook 2007 Contact Form Code Not Working Using Outlook 20
M Updating VBA code from outlook 2007 to outlook 2010 Using Outlook 1
K Outlook 2007 Error Code 0x80040607 Using Outlook 10
D Outlook 2007 Recovering E-Mails Using Outlook 0
W Transfer Outlook 2016 autocomplete file to Outlook 2007 Using Outlook 1
C Outlook 2007 Removing then adding account restores junk email processing Using Outlook 0
S Outlook 2007 crash linked to gdiplus.dll Using Outlook 0
S Outlook 2007 - Automatic purge fail Using Outlook 0
J outlook 2007 doesn't let me choose which .pst to search Using Outlook 2
D Outlook 2007 vs. Outlook 2010 -- ToDo Bar Using Outlook 0
D Outlook 2007 on 365 Using Outlook.com accounts in Outlook 2
S Macro for other actions - Outlook 2007 Outlook VBA and Custom Forms 23
S Verwendung von Outlook 2007 Using Outlook 0
A Arthur needs help with 2007 Outlook e-mail Using Outlook.com accounts in Outlook 3
M PST import from Outlook 2007 to 2010 - Address Book contacts all in 1 group Using Outlook 4
S outlook 2007 calendar search Using Outlook 6
B Migrate Outlook 2007 to Office 365 Using Outlook 3
X I have met my waterloo trying to resolve embedded graphics problem with outlook 2007 and now 2016 Using Outlook 1
R Outlook 2007 only loads some appointments Using Outlook 0
C Move Outlook 2007 to new PC with Outlook 365 Using Outlook 3
J Outlook 2007 Hide Messages Option not Available Using Outlook 2
S Outlook 2007 Calendar instant search problem. Windows 7 Using Outlook 4
S Outlook 2007 Calendar instant search problem. Windows 7 Using Outlook 0
B Server errors Outlook 2007 Using Outlook 1
S Reboot of frozen windows7 results in changed outlook 2007 settings Using Outlook 1
S Outlook 2007 printing wrong email address at top of page Using Outlook 8
M Configure outlook 2007 to accept digital signatures Using Outlook 2
D Outlook 2007 crashes when opening an email Using Outlook 2
R New chap saying hello and needing advice on Outlook 2007 thumbnails Using Outlook 3
icacream From Outlook 2007 to 2016 ! Using Outlook 9
vodkasoda Object could not be found Error in Outlook 2007 Outlook VBA and Custom Forms 5
S Outlook 2007: Address Cards allow entering text! Why? Using Outlook 3
S View Appointment in Text Wrap in Outlook 2007 Month Calendar View Using Outlook 0
L Outlook 2007 Separate the Send/Receive functions Using Outlook 2
M Outlook 2007 Contacts Glitch: Creating a new email Using Outlook 1
C Move from Outlook 2007 Enterprise (MOE) to Outlook Pro plus 2007 Using Outlook 1
J reinstalling Outlook 2007 asking for user name & password Using Outlook 14
P outlook addin unloaded in office 2007 Using Outlook 0
B Fonts in Outlook 2007 Using Outlook 4
R Add Exchange Account to existing POP3 Outlook 2007 Profile Using Outlook 0
C out of space in file group Outlook 2007 Using Outlook 2
A Moving archived contents in Outlook 2007 back into working folders Using Outlook 0
P Outlook 2007 Email Categorization using VBA Outlook VBA and Custom Forms 1
M Unable to Configure Gmail Account in Outlook 2007 Using Outlook 1
R Outlook 2007 or 2010 - Lock Down Functionality Outlook VBA and Custom Forms 3
S Outlook 2007, windows 10 Font size Using Outlook 1
Diane Poremsky Manually create a POP3 account in Outlook 2007 Using Outlook 0
J Can Click to Drag Custom Form Field But Cannot Drop When Designing in Outlook 2007 Outlook VBA and Custom Forms 2
L Outlook 2007 Font Using Outlook 3
J Outlook 2007 connector and Windows 10 Using Outlook 3

Similar threads

Back
Top