Consulting

Results 1 to 4 of 4

Thread: copy and paste in certain location in word

  1. #1
    VBAX Regular
    Joined
    Oct 2012
    Posts
    85
    Location

    copy and paste in certain location in word

    I have some data in an excel document that I copy from excel and paste into word. It is easy to paste this excel data into a new, blank word document with the below code.

    Sub Test()
        Dim FName           As String
        Dim FPath           As String
    Sheets("Sheet1").Range("A3:G80").CopyPicture Appearance:=xlScreen, Format:=xlPicture
    With CreateObject("Word.Document")
        .Application.Selection.PasteSpecial Link:=False, DataType:=wdPasteEnhancedMetafile, _
        Placement:=wdInLine, DisplayAsIcon:=False
        FPath = "C:\Users\kl\Desktop"
        FName = Sheets("Sheet1").Range("A6").Text
        .SaveAs2 Filename:=FPath & "\" & FName
        .Close 0
    End With
    End Sub
    However, I would like to paste into a word document that already has some text and a border (see attached). But it won't work because of the text at the top. That is why I am wondering if I can direct my cursor to be in a position lower than the text up top so the excel data will paste.
    Attached Files Attached Files

  2. #2
    VBAX Regular
    Joined
    Oct 2012
    Posts
    85
    Location
    I tried to add

    .Application.TypeParagraph above the Application.Selection line but I get an error.

    Sub Test() Dim FName As String Dim FPath As String Sheets("Sheet1").Range("A3:G80").CopyPicture Appearance:=xlScreen, Format:=xlPicture With CreateObject("Word.Document") .Application.Selection.TypeParagraph .Application.Selection.TypeParagraph .Application.Selection.PasteSpecial Link:=False, DataType:=wdPasteEnhancedMetafile, _ Placement:=wdInLine, DisplayAsIcon:=False FPath = "C:\Users\kl\Desktop" FName = Sheets("Sheet1").Range("A6").Text .SaveAs2 Filename:=FPath & "\" & FName .Close 0 End With End Sub

  3. #3
    VBAX Regular
    Joined
    Oct 2012
    Posts
    85
    Location
    Any ideas?

  4. #4
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Add a bookmark and paste it there.

    Option Explicit
    'TypeText method
    ' http://www.excelforum.com/excel-prog...ml#post1946784
    ' http://www.excelforum.com/showthread.php?p=1946784
    ' http://vbaexpress.com/forum/showthread.php?p=169877
    ' http://vbaexpress.com/forum/showthread.php?t=24693
    ' http://www.excelforum.com/excel-prog...age-setup.html

    'Copy from Excel, paste to Word
    'Lucas, http://vbaexpress.com/forum/showthread.php?p=178364

    'FormFields
    ' http://www.mrexcel.com/forum/showthread.php?p=1639696
    ' http://www.mrexcel.com/forum/showthread.php?t=333200
    ' http://www.excelforum.com/excel-prog...from-word.html
    ' Content Controls
    ' http://www.vbaexpress.com/forum/showthread.php?t=39654

    'Add Hyperlink to Bookmark
    ' http://www.excelforum.com/excel-prog...ml#post2006430
    'Steiner, http://www.vbaexpress.com/kb/getarticle.php?kb_id=126
    'Colin_L, http://www.mrexcel.com/forum/showthread.php?t=358054

    'Save OLEObject as MSWord Document
    ' http://vbaexpress.com/forum/showthread.php?t=21619

    'Add Table to MSWord
    ' http://vbaexpress.com/forum/showthread.php?t=23975
    ' http://vbaexpress.com/forum/showthread.php?p=168731

    'Import Word Tables
    'vog, http://www.mrexcel.com/forum/showthread.php?t=382541

    'Save OLEObject as MSWord DOC
    ' http://vbaexpress.com/forum/showthread.php?t=21619

    'Get Optionbutton info from MSWord DOC
    ' http://vbaexpress.com/forum/showthread.php?t=22454

    'FindReplace Text
    ' http://www.excelforum.com/excel-prog...-ms-excel.html
    ' http://www.vbaexpress.com/forum/showthread.php?t=38958
    ' http://www.vbaexpress.com/forum/showthread.php?p=250215
    ' http://www.vbaexpress.com/forum/showthread.php?t=42833
    ' http://support.microsoft.com/kb/240157
    ' http://word.tips.net/T001833_Generat...currences.html

    ' http://www.excelforum.com/excel-prog...o-to-word.html

    'Bookmarks
    ' http://vbaexpress.com/forum/showthread.php?p=185718
    'Colin_L, http://www.mrexcel.com/forum/showthread.php?t=358054
    ' http://www.vbaexpress.com/forum/showthread.php?p=253277

    'Mail Merge
    ' http://www.excelforum.com/excel-prog...rom-excel.html
    ' http://www.excelforum.com/excel-prog...-document.html
    'Word 's Catalogue/Directory Mailmerge facility (the terminology depends on the Word version). _
    To see how to group records with any mailmerge data source supported by Word, _
    check out my Microsoft Word Catalogue/Directory Mailmerge Tutorial at:
    ' http://lounge.windowssecrets.com/ind...owtopic=731107
    ' or
    ' http://www.gmayor.com/Zips/Catalogue%20Mailmerge.zip

Posting Permissions

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