Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Location of the selection on the page (Word 2K & greater)

    I am writing an excel macro to use CopyPicture to copy a chart sheet. I want to paste the picture into an open Word document at the insertion point with Top & Bottom text wrapping. How do I know how to set the Top property of the pasted Shape? I have
    <pre>Sub TestCopy()
    Dim wdApp As Word.Application
    Set wdApp = GetObject(, "Word.Application")
    Charts(1).CopyPicture Appearance:=xlPrinter, Format:=xlPicture
    wdApp.ActiveWindow.View.Type = wdPageView
    wdApp.Selection.PasteSpecial Placement:=wdFloatOverText
    With wdApp.Selection.ShapeRange
    .WrapFormat.Type = wdWrapTopBottom
    Dim iWidth As Long, iHeight As Long
    iWidth = .Width
    iHeight = .Height
    .Width = InchesToPoints(5.5)
    .Height = iHeight * .Width / iWidth
    .top = InchesToPoints(1.5)
    .Left = 0
    End With
    wdApp.Activate
    End Sub
    </pre>


    This works fine, but I want to replace the .top = InchesToPoints(1.5) with something so that the picture starts where the insertion point was initially. TIA --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Location of the selection on the page (Word 2K & greater)

    You can use Selection.Information(wdVerticalPositionRelativeTo Page) to obtain the vertical position of the current selection/insertion point relative to the top of the page.

  3. #3
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Location of the selection on the page (Word 2K & greater)

    Thanks, Hans, that looks like exactly what I need. I'm side-tracked, now. Hopefully, I can test it later today. --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

Posting Permissions

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