Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 09-14-2015, 09:56 PM
peligroso peligroso is offline vba find numbers in document and align text left Windows 8 vba find numbers in document and align text left Office 2013
Novice
vba find numbers in document and align text left
 
Join Date: Sep 2015
Posts: 6
peligroso is on a distinguished road
Default

Hi macropod, thanks so much for the response. I will admit that I am the worst type of programmer (IT exec playing as required to get reports out) so I am happy to hear any feedback, good or bad.

To answer your question, the process is to select a range in excel that contains the table data and then do a search for a placeholder in the word document. For example:

Range("dep_comparison_table").Copy
wrdObj.Selection.Find.Text = "<dep_comparison_table>"
Call FormatPaste
wrdObj.Selection.MoveLeft Unit:=wdCharacter, Count:=20
wrdObj.Selection.Tables(1).AllowAutoFit = False
wrdObj.Selection.Tables(1).PreferredWidth = wrdObj.CentimetersToPoints(18.4)

Sub FormatPaste()

wdFind.Replacement.Text = ""
wdFind.Forward = True
wdFind.Wrap = wdFindContinue
wdFind.Execute
Call CheckClipBrd
wrdObj.Selection.Paste
CutCopyMode = False

End Sub

After all the tables are copied the tables are formatted with the following:

For Each Table In wrdDoc.Tables
Table.Select
For i = 1 To Table.Rows.Count
Table.Rows(i).Range.ParagraphFormat.KeepTogether = True
If i < Table.Rows.Count Then
Table.Rows(i).Range.ParagraphFormat.KeepWithNext = True
End If
Next i
Next Table
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
vba find numbers in document and align text left How to either move document display to right or left; or reduce size of find/replace window. pmstock Word 2 08-02-2014 08:34 PM
vba find numbers in document and align text left Find and Replace function shooting off screen to the left of the document Mattblack Word 1 04-10-2014 03:06 PM
vba find numbers in document and align text left Align...both left and right? supersimu Word 1 01-25-2014 02:05 AM
vba find numbers in document and align text left Numbers on the left side of the text Felipe Word 2 04-19-2012 07:35 AM
vba find numbers in document and align text left How to align page to left side instead of centre ghumdinger Word 2 08-18-2011 10:15 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:04 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft