Solved

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

Posted on 2006-10-24
13
231 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

777 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