Results 1 to 2 of 2

Thread: controlling MS Word from Excel

  1. #1

    controlling MS Word from Excel



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi all
    thank you for reading this.

    I am trying to write a macro to control a Word document (wrdDoc) from Excel VBA. However the syntax is quite different between them.

    The first line is working, I cannot get the right syntax for the rest.
    Any help please ?
    cheers
    Julien

    [VBA]Sub createTableUnderlying(nbUnderlyings, leUnd)
    'Go to Fund Ticker


    wrdDoc.bookmarks("FundTicker").Select
    With Selection.Cells
    .Split NumRows:=nbUnderlyings, NumColumns:=4, MergeBeforeSplit:=False
    End With

    'Need to select table
    wrdDoc.bookmarks("FundTicker").Select
    wrdDoc.Selection.MoveDown Unit:=wdLine, Count:=nbUnderlyings, Extend:=wdExtend
    wrdDoc.Selection.MoveRight Unit:=wdCharacter, Count:=3, Extend:=wdExtend
    wrdDoc.Selection.SelectCell
    wrdDoc.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
    wrdDoc.Selection.Cells.VerticalAlignment = wdCellAlignVerticalCenter
    With Selection.Cells
    With .Borders(wdBorderTop)
    .LineStyle = wdLineStyleSingle
    .LineWidth = wdLineWidth050pt
    .Color = wdColorAutomatic
    End With
    With .Borders(wdBorderBottom)
    .LineStyle = wdLineStyleSingle
    .LineWidth = wdLineWidth050pt
    .Color = wdColorAutomatic
    End With
    With .Borders(wdBorderHorizontal)
    .LineStyle = wdLineStyleSingle
    .LineWidth = wdLineWidth050pt
    .Color = wdColorAutomatic
    End With
    With .Borders(wdBorderVertical)
    .LineStyle = wdLineStyleSingle
    .LineWidth = wdLineWidth050pt
    .Color = wdColorAutomatic
    End With
    End With
    ' With Options
    ' .DefaultBorderLineStyle = wdLineStyleSingle
    ' .DefaultBorderLineWidth = wdLineWidth050pt
    ' .DefaultBorderColor = wdColorAutomatic
    ' End With

    End Sub[/VBA]
    Last edited by JPL007; 2012-11-02 at 03:29 PM.

  2. #2
    I particularly need help with

    With Selection.Cells
    .Split NumRows:=nbUnderlyings, NumColumns:=4, MergeBeforeSplit:=False
    End With

    Thank you

Posting Permissions

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