+ Reply to Thread
Results 1 to 6 of 6

vbnewline at strbody is not working. Please help

  1. #1
    Registered User
    Join Date
    11-27-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    66

    vbnewline at strbody is not working. Please help

    Hi,

    My code, vbnewline at strbody, is not functioning. Please help (refer to code)


    PHP Code: 
    Private Declare Function ShellExecute Lib "shell32.dll" _
    Alias 
    "ShellExecuteA" (ByVal hwnd As LongByVal lpOperation As String_
    ByVal lpFile 
    As StringByVal lpParameters As StringByVal lpDirectory As String_
    ByVal nShowCmd 
    As Long) As Long

    Private Sub Workbook_SheetChange(ByVal Sh As ObjectByVal Target As Range)
        
    Dim lngResponse As Long
        Dim URL 
    As StringstrEmail As StringstrSubject As Stringstrbody As String
        
        
    If Left(Target.Address2) = "$DThen
            
    If Target.Value Range("$ERight(Target.Address2)).Value Then
                lngResponse 
    MsgBox("The inventory quantity for this item has dropped below the reorder level. Would you like to reorder this item?"vbYesNo)
                If 
    lngResponse vbYes Then
                    strEmail 
    Range("$IRight(Target.Address2)).Value
                    strSubject 
    "New order for " Range("$FRight(Target.Address2)).Value " '" Range("$BRight(Target.Address2)).Value "' items. The remaining " "'" Range("$BRight(Target.Address2)).Value "' was " Range("$DRight(Target.Address2)) & ". This data was capture on " Format(Now"dd-mmm-yy, hh:mm AM/PM")
                    
    strbody "Dear Sir/Madam" vbNewLine vbNewLine "Hi"
                    
    strSubject Application.WorksheetFunction.Substitute(strSubject" ""%20")
                    
    strbody Application.WorksheetFunction.Substitute(strbody" ""%20")
                    
    strURL "mailto:" strEmail "?subject=" strSubject "&body=" strbody
                    ShellExecute 0
    &, vbNullStringstrURLvbNullStringvbNullStringvbNormalFocus
                End 
    If
            
    End If
        
    End If
    End Sub 
    BR
    KC

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: vbnewline at strbody is not working. Please help

    Try vbCrLf instead.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    11-27-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: vbnewline at strbody is not working. Please help

    Try vbCrLf before, it is not working as well...

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: vbnewline at strbody is not working. Please help

    Hello alexnkc,

    Try replacing strNewLine with the characters %0A0D. This is the UTF-8 encoding for Chr(10) Chr(13) or a new line in Windows.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Registered User
    Join Date
    11-27-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: vbnewline at strbody is not working. Please help

    Hi Leith Ross,

    With slightly modification on %OAOD, it is working.
    "%OA" - is the way for me to create new line.

    Many thanks...

    BR
    KC

  6. #6
    Registered User
    Join Date
    11-27-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    66

    Red face Re: vbnewline at strbody is not working. Please help

    Hi Leith Ross,

    With slightly modification on %OAOD, it is working.
    "%OA" - is the way for me to create new line.

    Many thanks...

    BR
    KC

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1