PDA

View Full Version : Copy a cell from excel to word and aligning center using VBA



blakeobeans
08-01-2012, 05:17 PM
Office 2010, Windows 7

I'm trying to copy a cell from Excel to Word and align it in the center of the word document using VBA. I'm very particular with retaining the paste special type in order to remain consistency with the larger project. Below is the code that I'm using:



Activecell.Select
Selection.Copy
wdApp.Visible = True
wdApp.Selection.PasteSpecial Link:=False, DataType:=1, Placement:=wdInLine, DisplayAsIcon:=False

I suppose there are many ways to do this, but I can't figure out a single one!

Thanks,
Blake

Tinbendr
08-02-2012, 07:26 AM
Crossposted (http://www.mrexcel.com/forum/showthread.php?650889-Using-VBA-to-Copy-text-from-Excel-to-Word-and-aligning-center&highlight=excel+word)

It is a violation of the board rules to post the same question on multiple boards without providing a link.

try

wdApp.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter

blakeobeans
08-02-2012, 10:03 AM
yes, but I must select the text first, which I haven't done!

Tinbendr
08-02-2012, 10:12 AM
Are you saying that the text isn't selected after PasteSpecial?