[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Word Automation - paragraphs and bullets

Posted on 2001-08-13
15
Medium Priority
?
1,036 Views
Last Modified: 2010-05-18
As a follow-on to this question:

http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=msaccess&qid=20164520 

I now want to produce a report in Word 97 based on an Excel 97 spreadsheet. I want some addition to this code which will mean that we loop through the code transferring row by row the text from columns A->D but putting a bullet point at the start of the text from column A. I would also like to have a vbcrlf seperating every row of the spreadsheet when shown on the Word document - any ideas?


Private Sub cmdTest_Click()
Dim wordapp As Word.Application
Dim worddoc As Word.Document
Set wordapp = CreateObject("Word.Application")
wordapp.Documents.Add
wordapp.Visible = True
Set worddoc = wordapp.ActiveDocument
introw = 1
Do While Trim(Worksheets("Highlights").Range("A" & introw).Value) <> ""
wordapp.Selection.EndKey wdStory
wordapp.Selection.Range.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries( _
       wdBulletGallery).ListTemplates(1), ContinuePreviousList:=False, ApplyTo:= _
       wdListApplyToWholeList
wordapp.Selection.TypeText Worksheets("Highlights").Range("A" & introw).Value 'Type text from Excel in selection (cursor)
wordapp.Selection.TypeParagraph
wordapp.Selection.EndKey wdStory
wordapp.Selection.TypeText Worksheets("Highlights").Range("B" & introw).Value 'Type text from Excel in selection (cursor)
wordapp.Selection.TypeParagraph
wordapp.Selection.EndKey wdStory
wordapp.Selection.TypeText Worksheets("Highlights").Range("C" & introw).Value 'Type text from Excel in selection (cursor)
wordapp.Selection.TypeParagraph
wordapp.Selection.EndKey wdStory
wordapp.Selection.TypeText Worksheets("Highlights").Range("D" & introw).Value 'Type text from Excel in selection (cursor)
wordapp.Selection.TypeParagraph
introw = introw + 1
Loop
End Sub
0
Comment
Question by:robertsmith28
[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
  • 10
  • 4
15 Comments
 
LVL 4

Expert Comment

by:WolfgangKoenig
ID: 6380596
VBcrlf equals to:
Selection.TypeParagraph

WoK ;O)
0
 

Author Comment

by:robertsmith28
ID: 6381367
Thanks - any ideas how I prevent the bullets at the start of line?
0
 
LVL 1

Expert Comment

by:eeevans
ID: 6382254
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Expert Comment

by:eeevans
ID: 6382259
0
 
LVL 1

Expert Comment

by:eeevans
ID: 6382275
0
 
LVL 1

Expert Comment

by:eeevans
ID: 6382282
0
 
LVL 1

Expert Comment

by:eeevans
ID: 6382284
0
 
LVL 1

Expert Comment

by:eeevans
ID: 6382286
0
 
LVL 1

Expert Comment

by:eeevans
ID: 6382290
0
 
LVL 1

Expert Comment

by:eeevans
ID: 6382434
You might want to put it in Word as a table instead.
To do that, I would have 4 strings that you concatonate
the row value to the end of it separating it by vbTab and
then get the current position.
Then do a
  Selection.typetext sRowA & vbCR & vbCR & sRowB & vbCR & vbCR & sRowC & vbCR & vbCR & sRowD
Then get the current position again and do a
  Range(initPosition, finalPosition).Select
  Selection.ConvertToTable(wdSeparateByTabs,introw)

At this point you could format it to highlight the
background of every other line to maybe give the same
effect as the bullets.

Would this work for you?

BTW, the ConvertToTable is much faster than stuffing into
table cells.

Regards,

eeevans
0
 

Author Comment

by:robertsmith28
ID: 6384008
Thanks eeevans,
The I'm producing needs to be in an exact format - so it's got to be the bullet-points, unfortunately. Thanks for the tips though.
0
 
LVL 1

Expert Comment

by:eeevans
ID: 6385742
No problem Robert.  To try and understand your format an example of what you are trying to produce would help but, I assume you need it to look like

. A1_text  

. B1_text

. C1_text    

. D1_text

. A2_text  

. B2_text    

. C2_text    

. D2_text


etc. where the periods in front are to be bullets and blank lines are in between.  Is this correct?

To do this you would just add the code to turn on the bullets before each wordapp.Selection.TypeText and add & vbCR & vbCR & vbCR at the end of that line.  The second vbCR will give you the blank line and the third vbCR will drop to the next line and turn off the bullets for the blank line and the current line.  Then you just repeat the code to turn on bullets etc.

Hope that helps,

eeevans
0
 

Author Comment

by:robertsmith28
ID: 6387270
Thanks for sticking with me eeevans, I'm new to working with Word so it may well be that the answer is simple but I can't see why my code does n't do what I think it should! What I would like it to do (using your format) is:

<bullet> A1_text
B1_text
C1_text
D1_text

<bullet> A2_text
B2_text
C2_text
D2_text

<bullet> A3_text
etc..

What I get is quite different. Any ideas?
0
 
LVL 1

Accepted Solution

by:
eeevans earned 800 total points
ID: 6388182
Okay, after your A#_text put this line

wordapp.Selection.Range.ListFormat.RemoveNumbers NumberType:=wdNumberParagraph

that should turn off the bullets for the last 3 items.  Also it looks like you need to add another

wordapp.Selection.TypeParagraph

after the last one in your code above to give the blank line between sets.

Let me know if that gets you closer.

eeevans
0
 

Author Comment

by:robertsmith28
ID: 6388918
That's grrreat! Job done. Thank you for all your help!

Rob :->
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

649 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