question on word vba .Paragraphs.SpaceBefore = 0

jamilm

Well-known Member
Joined
Jul 21, 2011
Messages
740
Gurus,

i am using excel vba with word object library to create a memo from the ranges in excel cells.

now i am typing some texts and when i moved from my first typetext to the second with type paragraph then there is a considerablly big space between first line and the second line. i can remove that via word document manually "Line and Paragraph Spacing" on the dropdown "Remove Space After Paragraph" however i am trying to perform the same manual thing through the VBA code. i searched through Google and i found in some forums that either .Paragraphs.SpaceBefore = 0 or .Paragraphs.SpaceAfter = 0 which work, however i tried and still did not work. i do not know where to put the .Paragraphs.SpaceAfter = 0 either before the second text or after it. any help would be appreciated.

P.S when i use record macro to check how macro is recording the code. unfortunately recording macro does not record any code for "Line and Paragraph Spacing" on the dropdown "Remove Space After Paragraph".


Code:
With WordApp
            .Documents.Add
            With .Selection
.TypeText Text:="Project Advances and Project Expenses"
.TypeParagraph
.TypeText Text:="Project Budget & Project Cash"
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
HTH. Dave
Code:
With WordApp
.Documents.Add
With .Selection
.TypeText Text:="Project Advances and Project Expenses" & vbCrLf
.TypeParagraph
.TypeText Text:="Project Budget & Project Cash" & vbCrLf
 
Upvote 0
thanks. but it did not work



HTH. Dave
Code:
With WordApp
.Documents.Add
With .Selection
.TypeText Text:="Project Advances and Project Expenses" & vbCrLf
.TypeParagraph
.TypeText Text:="Project Budget & Project Cash" & vbCrLf
 
Upvote 0
There's no space when I use the code. Are there any tab settings or styles in the document? Beyond that I've got no idea why it doesn't work for you. Good luck. Dave
 
Upvote 0

Forum statistics

Threads
1,215,692
Messages
6,126,223
Members
449,303
Latest member
grantrob

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top