Solved

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

Posted on 2006-10-24
13
230 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now