Solved

vbCrLf does not work in MS Work in Macro / Document Template

Posted on 2006-10-24
13
232 Views
Last Modified: 2013-12-25
I need the following to have 3 seperate paragraphs.
I've tried a lot of things, nothing works for me.
I'm a bit green to VB, but I cannot locate the proper syntax to put carraige returns and line feeds where I need them.
The example below puts everything on one blurb of text.
(it's part of my complete script, it's this part I need to break into 3 paragraphs).
--------------------------------------------------------------------------------------------------
If strSalesman = "BOB" Then
        Selection.TypeText Text:="As I mentioned, we have an experienced chemical " _
        + "engineer on staff who is available for emergencies or consultations, day or night." _
        + "I am intimately involved with every aspect of our operations " _
        + "planning and quality control.  Our competence and service, backed " _
        + "by thorough supervision on every job, are in the forefront of our industry." _
        + "Our company was founded to service discerning organizations, " _
        + "like yours and if given the opportunity to service your facilities, " _
        + "I will not let you down.  You have my personal guarantee."

        Selection.GoTo What:=wdGoToBookmark, Name:="bkrep"
        Selection.TypeText ("Mighty Mouse")
    End If
--------------------------------------------------------------------------------------------------

THIS IS THE EXACT LAYOUT I NEED:

As I mentioned, we have an experienced chemical engineer on staff who is available for
emergencies or consultations, day or night.

I am intimately involved with every aspect of our operations planning and quality control.  
Our competence and service, backed by thorough supervision on every job, are in the
forefront of our industry.

Our company was founded to service discerning organizations, like yours and if given the
opportunity to service your facilities, I will not let you down.  You have my personal
guarantee.

--------------------------------------------------------------------------------------------------

Can anyone help?

Thanks much in advance.
0
Comment
Question by:guruuno
  • 4
  • 3
  • 2
  • +2
13 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 17799626
This doesn't work?

Selection.TypeText Text:="blah blah blah " & vbCrLf  _
    + "blah blah blah." & vbCrLf _
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 17799630
Or use chr(13) in place of vbCrLf
0
 
LVL 1

Author Comment

by:guruuno
ID: 17800093
I found that by Google-ing, and it does not work.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 15

Expert Comment

by:JackOfPH
ID: 17800781
try
Selection.TypeText Text:="blah blah blah " & vbcr + vblf  _
    + "blah blah blah." & vbcr + vblf
0
 
LVL 1

Author Comment

by:guruuno
ID: 17800890
I tried as below, did not work.  Also, on the LAST line, how do I get the carraige return/line feed? (in addition to the areas I added the  & vbcr + vblf  _)
(+ "I will not let you down.  You have my personal guarantee.")
As, if I add anything after ......personal guarantee.", I get a compile error.
-------------------------------------------------------------------------------------

If strSalesman = "BOB" Then
        Selection.TypeText Text:="As I mentioned, we have an experienced chemical " _
        + "engineer on staff who is available for emergencies or consultations, day or night." & vbcr + vblf  _
        + "I am intimately involved with every aspect of our operations " _
        + "planning and quality control.  Our competence and service, backed " _
        + "by thorough supervision on every job, are in the forefront of our industry." & vbcr + vblf  _
        + "Our company was founded to service discerning organizations, " _
        + "like yours and if given the opportunity to service your facilities, " _
        + "I will not let you down.  You have my personal guarantee."

        Selection.GoTo What:=wdGoToBookmark, Name:="bkrep"
        Selection.TypeText ("Mighty Mouse")
    End If
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 17801224
Try using the "&" instead of + as connector...
If strSalesman = "BOB" Then
        Selection.TypeText Text:="As I mentioned, we have an experienced chemical " _
        & "engineer on staff who is available for emergencies or consultations, day or night." & vbcr + vblf  _
        & "I am intimately involved with every aspect of our operations " _
        & "planning and quality control.  Our competence and service, backed " _
        & "by thorough supervision on every job, are in the forefront of our industry." & vbcr + vblf  _
        & "Our company was founded to service discerning organizations, " _
        & "like yours and if given the opportunity to service your facilities, " _
        & "I will not let you down.  You have my personal guarantee."

        Selection.GoTo What:=wdGoToBookmark, Name:="bkrep"
        Selection.TypeText ("Mighty Mouse")
    End If
0
 
LVL 6

Expert Comment

by:saravananvg
ID: 17801276
Hello Sir,

  Check the following sample.

strMessage = "The WOL packet was sent:" & vbcrlf & vbcrlf _
   & "Packet Status:" & vbTab & strStatus & vbcrlf _
   & "Broadcast Address:" & vbTab & strBroadcastAddr & vbcrlf _
   & "MAC Address:" & vbTab & strMACAddr & vbcrlf _
   & "Using Interface:" & vbTab & strLocalIP


In the samples already post above, I think it should be &vbcrlf & vbcrlf_      instead of vbcr + vblf_

with regards,
padmaja.
0
 
LVL 1

Author Comment

by:guruuno
ID: 17803126
Tried both of the last 2 examples, still a no go.
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 17803231
Another method to try...

Dim strMessage as string

strMessage = "blah blah blah " & vbCrLf
strMessage = strMessage & "blah blah blah blah blah blah blah " & vbCrLf
strMessage = strMessage & "blah blah blah blah blah blah blah " & vbCrLf
strMessage = strMessage & "blah blah blah blah blah blah blah " & vbCrLf
strMessage = strMessage & "blah blah blah blah blah blah blah " & vbCrLf

YourControl.YourProperty = strMessage
0
 
LVL 1

Author Comment

by:guruuno
ID: 17803251
I got it to work with the following, thanks for all, but I haced all night to get it.
=================================================
If strSalesman = "BOB" Then
        Selection.TypeText Text:="As I mentioned, we have an experienced chemical " _
        + "engineer on staff who is available for emergencies or consultations, day or night." & vbCrLf _
       
        Selection.TypeParagraph
        Selection.TypeText Text:="I am intimately involved with every aspect of our operations " _
        + "planning and quality control.  Our competence and service, backed " _
        + "by thorough supervision on every job, are in the forefront of our industry." & vbCrLf _

        Selection.TypeParagraph
        Selection.TypeText Text:="Our company was founded to service discerning organizations, " _
        & "like yours and if given the opportunity to service your facilities, " _
        & "I will not let you down.  You have my personal guarantee." _

        Selection.GoTo What:=wdGoToBookmark, Name:="bkrep"
        Selection.TypeText ("Mickey Mouse")
    End If
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 18184077
PAQed with points refunded (250)

Computer101
EE Admin
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question