Outlook 2007 Code for Note Fields of Appointment

Status
Not open for further replies.
itmAppt.Body = "Mobile Number" & " - " & item.getinspector.modifiedformpages("General").con trols("Phone4").text & vbcrlf & "Business Number" & " - " & item.getinspector.modifiedformpages("General").con trols("Phone1").text

try this

Dim txtMobile as string

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

txtmobile = "Mobile Number" & " - " & item.getinspector.modifiedformpages("General").con trols("Phone4").text & vbcrlf

else

txtmobile = ""

end if

repeat for other fields then put them together in the body -

itmappt.body = txtMobile & txtbusiness
 
I did exactly what you posted and it does not add any words or phone numbers to the body when the contact has phone numbers
 
I'm sure the problem is in the if statement - i don't know if you need to use not = "

If Not Item.GetInspector.ModifiedFormPages("General").Controls("Phone4").Text = "" Then

or if you'll need to do it some other way with the controls.

If you comment out the if/end if lines, is something added to the body? This will test the string code and verify it is working.
 
thanks....don't understand the statement to comment out the if/end lines.....what should I do please?

And there is the error "expect end of statement, line 11" and line 11 is the Dim txtMobile as string
 
that is where you add an apostrophe to the beginning of the line so it doesn't work - it turns green

' if item.getinspector.modifiedformpages("General").con trols("Phone4").text <> "" then
txtmobile = "Mobile Number" & " - " & item.getinspector.modifiedformpages("General").con trols("Phone4").text & vbcrlf

' else
txtmobile = ""

' end if

if setting txtmobile to = the value and then adding to the body works, we know its the if statement that is not working.
 
As I repeat, I don't have this expertise, so what lines should i just take out as the ' in a script does not turn anything green. And what do I add as value to that other line? Thanks very much.
 
I did what you mentioned and had forgot to put the ' in front of the Else word....did it, and it shows the words and the phone numbers in the body......but when I don't have phone number, it still shows the words that I don't need to have in it
 
These are the code lines that we have added and each one has the first words and then the value from the specific conrol area......

So how can we adjust it so if there is not information in the value of the specifice control area, then I do not want the first words to show up on the body.

And secondly, how can we make all the words and values that show up in the body, as a different font and bold.....as I redid the form of the appointment, but it is not coming up as the different font and bold color.

Dim txtMobile

Dim txtBusiness

Dim txtlaststatus

txtMobile = "Mobile Number" & ": " & item.getinspector.modifiedformpages("General").controls("Phone4").text & vbcrlf

txtBusiness = "Business Number" & ": " & item.getinspector.modifiedformpages("General").controls("Phone1").text & vbcrlf

txtlaststatus = "Last Status" & ": " & item.getinspector.modifiedformpages("General").controls("ComboBox9").text & vbcrlf

itmappt.body = txtMobile & txtbusiness & txtlaststatus
 
Update for both questions tonight? Also, i there a macro that simple selects all words in the body field of the calendar event, and changes to the font to what I want...which would be Times New Roman, Bold, and 16 size and also, here is the code I recorded in Word to do it, but don't know how to change for Outlook....and of course, if the code in the script can create the font for the words that come from running the script that would be great.....

Sub Macro5()

'

' Macro5 Macro

'

'
Selection.WholeStory
Selection.Font.Bold = wdToggle
Selection.Font.Size = 16

End Sub
 
I did what you mentioned and had forgot to put the ' in front of the Else word....did it, and it shows the words and the phone numbers in the body......but when I don't have phone number, it still shows the words that I don't need to have in it

This is to be expected when the if lines are commented out. I wanted to make sure the problem wasn't with that statement.
 
You need to use an if statement that skips the line if there is no value. I'm not sure why it wasn't working...

Do all of the numbers have a characters - like a dash or period - that will be present if the field contains a number? If so, you can look for that
if instr(1, txtmobile, "-") then
itmappt.body = txtMobile

end if
if instr(1, txtbusines, "-") then
itmappt.body = itmappt.body & txtBusiness

end if
 
Do I add the if statements to the current codes which are the following or do I delete some of this and if they are not deledted, where do I put the if statements please?

:

txtMobile = "Mobile Number" & ": " & item.getinspector.modifiedformpages("General").con trols("Phone4").text & vbcrlf

txtBusiness = "Business Number" & ": " & item.getinspector.modifiedformpages("General").con trols("Phone1").text & vbcrlf

txtlaststatus = "Last Status" & ": " & item.getinspector.modifiedformpages("General").con trols("ComboBox9").text & vbcrlf

itmappt.body = txtMobile & txtbusiness & txtlaststatus


 
I put the following code that you gave me: if instr(1, txtmobile, "-") then
itmappt.body = txtMobile
end if

and I put it under the line: txtMobile = "Mobile Number" & ": " & item.getinspector.modifiedformpages("General").con trols("Phone4").text & vbcrlf and when I run where there is not phone number, the words "Mobile Number" still show up in the body
 
In the past you gave me the code how I put words that a bold in an email.......so here is what you gave me before, and is there a way to this so my body words are bold?? Set objMsg = Application.CreateItem(olMailItem)
objMsg.HTMLBody = "<br /><p><b>Love You,<b> <br /><p><b>Dad</b></p><br />"
objMsg.To = oContact.Email1Address
objMsg.Subject = "From Dad"
objMsg.BodyFormat = olFormatHTML
MsgBody = objMsg.HTMLBody
 
Contact and apt bodies don't use HTML, you'd need to use RTF formatting, bot HTML. The other code will do it.

i don't know why the other code won't work. :(
 
The first line is showing up in the code as a color...do I change this first line? Public <span class="adtext" id="adtext_8">Sub</span> FormatSelectedText()
 
I did the following and it changes the font of the words I select in an email sending, but not the words I select in the body of a calendar appointment....so what do we change here and it will work perfectly..... Public Sub FormatSelectedText()
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 = olMail 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 = wdColorBlue
.Font.Size = 18
.Font.Bold = True
.Font.Italic = True
.Font.Name = "Arial"
End With
End If
End If
End If

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

End Sub
 
Just changed

If objItem.Class = olMail Then to If objItem.Class = olAppointment Then And it works!!! Thanks very much as usual!!! And just need what to change to the other code where there is not the value and don't want the words to show up
 
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