Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Spaces removed from string 2

Status
Not open for further replies.

dvirgint

Programmer
Jun 28, 2010
85
0
0
CA
Hello,

I have a macro which scrapes data from a mainframe emulation program called Attachmate Reflection into Excel to make various calculations for sales people. I have to scrape sales information for each salesman and send it to them in an email.

My problem is that once the screen information is in a variable (strScreenCapture), all extra spacing is removed. The page where I get my information is set up as a table and so it is important that the string retain extra spaces so the salesmen can correctly view their information.

In order to keep the spacing as it should be, I changed the font to Consolas. To do this, I use the following snippet:

Code:
With OutMail
       .To = strUser
        .Subject = "Your sales information for the week ending on " + strDate
        .htmlBody = "<p>Hello,,</p>" & _
                "<p>Here is your sales information the week ending on " & strDate & ".</p>" & _
                "<span style='font-family:consolas;font-size:11'>" & [highlight #FCE94F]strScreenCapture[/highlight] & "</span>"
                .Display
End With

I put my strScreenCapture variable into a message box to see its contents - the spaces were retained, however whenever I use HTML, it seems to cut the spaces. Does anyone have any way to correct this?

Thanks
 
hi,

Replace each SPACE with [highlight #FCE94F]%20[/highlight].

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
I found the answer to my own question.

If I use the <pre> tag instead of the <p> or <span> tags, it leaves the spacing as is.

 
Use non-breaking spaces, for this convert your strScreenCapture before assigning to htmlBody:
[tt]strScreenCapture = Replace(strScreenCapture, " ", "&#160;")[/tt]

combo
 
Thanks for all your help!! Works like a charm!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top