Solved

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

Posted on 2006-10-24
13
233 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

734 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