Consulting

Results 1 to 4 of 4

Thread: Copy a cell from excel to word and aligning center using VBA

  1. #1

    Copy a cell from excel to word and aligning center using VBA

    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

  2. #2
    VBAX Expert Tinbendr's Avatar
    Joined
    Jun 2005
    Location
    North Central Mississippi (The Pines)
    Posts
    993
    Location
    Crossposted

    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
    Last edited by Tinbendr; 08-02-2012 at 07:48 AM.

    David


  3. #3
    yes, but I must select the text first, which I haven't done!

  4. #4
    VBAX Expert Tinbendr's Avatar
    Joined
    Jun 2005
    Location
    North Central Mississippi (The Pines)
    Posts
    993
    Location
    Are you saying that the text isn't selected after PasteSpecial?

    David


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •