Forum

Simple string body ...
 
Notifications
Clear all

Simple string body to display in an email

5 Posts
4 Users
0 Reactions
72 Views
(@rogerisin)
Posts: 1
New Member
Topic starter
 

Good Afternoon,

I am having a terrible time writing a simple string body that pulls information from Excel workbook columns.

I've even tried copying the format from a macro that I wrote with similar functionality but it still doesn't work -even after I've change the lines of the string (code).

The Macro is named 'FedexinfoToSite on the attached workbook

Help and thanks in advance

 
Posted : 02/05/2023 1:06 pm
(@keebellah)
Posts: 373
Reputable Member
 

Hi Roger, you should keep in mind when attaching a file with data links you make sure they work for others.

We do not have access to the connection at your shareppoint sciuusa etc...

Your question is about the macro but a file that first needs to braek links or skip updates is a P in the A when trying to help

 
Posted : 03/05/2023 2:34 am
Philip Treacy
(@philipt)
Posts: 1630
Member Admin
 

Hi Roger,

You haven't actually said what the problem is, and any error that VBA generated would assist in finding the issue.

However after running the code I can see VBA gives a type mismatch error which indicates that, as you are trying to build a string, you are using something that isn't a string.

Looking at your code I see you are trying to include the FedEx tracking number in the string, but this is a number.

To make the code work you need to cast the number to the string type using the CStr function

strbody = "Good Afternoon " + Cells(I, 17).Value + "," _
& vbNewLine & vbNewLine _
& "The above's Fedex tracking number is " + CStr(Cells(I, 27).Value) + _
vbNewLine & vbNewLine & vbNewLine & vbNewLine _
& "Regards,"

Regards

Phil

 
Posted : 04/05/2023 8:45 pm
(@debaser)
Posts: 837
Member Moderator
 

Or use & consistently rather than + for concatenation. 🙂

 
Posted : 05/05/2023 3:30 am
(@keebellah)
Posts: 373
Reputable Member
 

Use Cells(I, 27).Text  instead

 
Posted : 06/05/2023 1:56 am
Share: