I use
Range("$AC" & Right(ActiveCell.Address, 2)).Value
to capture the contents of the column ACin the row of the selected cell. The cell content is a comment, I want the user to be able to write to include in the message that I generate using my macro. For example, at the moment, if you have "Commentary on student 3." without quotes in the cell, it is added to the body of the letter. The comment is included in the string strBodyand then included in the email using the following two commands (with the destination email address stored in strTo):
strURL = strTo & "&Body=" & strBody
and
ShellExecute 0&, vbNullString, strURL, vbNullString, vbNullString, vbNormalFocus
There are no problems so far. IF the user does not use a special character, for example, ?or "in the contents of an Excel cell. Using ?shortens the rest of the line when used "creates an error and cannot even generate email.
So here's the question: is there a way to encode a capture to format the contents of a cell to ignore a special character? Or I have a way in which a user can enter their comment so that it is ?simply viewed as ?. Note. I tried \? /? "?" "? '?and even something like that Microsoft.Visual.Chr(34).
EDIT:
@stucharo answer below worked perfectly! Thank you For those who ask for the minimum code to see what happens (this is still a mystery to me, as I am just Frankrinstein with this material):
Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Sub EmailStudent()
strTo = "mailto:Address@bmail.com"
strSubject = "Email Subject"
strBody1 = Range("'Sheet1'!A1")
strBody2 = Range("'Sheet1'!A2")
strBody3 = Range("'Sheet1'!A3")
strBody = strBody1 & "%0D%0A%0D%0A" & strBody2 & "%0D%0A%0D%0A" & strBody3
strBody = Replace(strBody, "?", "%3F")
strURL = strTo & "&subject=" & strSubject & "&Body=" & strBody
ShellExecute 0&, vbNullString, strURL, vbNullString, vbNullString, vbNormalFocus
End Sub
A1 A2 A3 Sheet1 . Outlook. , Replace A2, , A3, .