+ Reply to Thread
Results 1 to 5 of 5

Copying Cell data and pasting into word document?

Hybrid View

  1. #1
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Copying Cell data and pasting into word document?

    Is it possible in VBA to copy named range data and paste it in to new word document?, I intend using a command button to start the code where for arguments sake Range("A1") will have a name selected from a list which will be the name of the named range, on click of the button copy and paste the named range data (values only!) in to a newly opened word document, it doesnt matter if it is pasted in to the default position (where the cursor starts flashing) when you first open word.

    Any ideas?

    Regards,
    Simon

  2. #2
    aidan.heritage@virgin.net
    Guest

    Re: Copying Cell data and pasting into word document?


    Dim appwd As Object
    On Error GoTo notloaded
    Set appwd = GetObject(, "Word.Application")
    notloaded:
    If Err.Number = 429 Then
    Set appwd = CreateObject("Word.Application")
    End If
    appwd.Visible = True
    On Error GoTo 0
    With appwd
    .typetext range("whatever").value
    end with


    Simon Lloyd wrote:
    > Is it possible in VBA to copy named range data and paste it in to new
    > word document?, I intend using a command button to start the code where
    > for arguments sake Range("A1") will have a name selected from a list
    > which will be the name of the named range, on click of the button copy
    > and paste the named range data (values only!) in to a newly opened word
    > document, it doesnt matter if it is pasted in to the default position
    > (where the cursor starts flashing) when you first open word.
    >
    > Any ideas?
    >
    > Regards,
    > Simon
    >
    >
    > --
    > Simon Lloyd
    > ------------------------------------------------------------------------
    > Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
    > View this thread: http://www.excelforum.com/showthread...hreadid=549029



  3. #3
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    Hi Aidan thanks for the reply, i tried running the code in a seperate module, and got the error "run time error '438' Object doesn't support this property or method"

    Any ideas why this might be?, the code opened the Word window but no document (no blank page).

    Regards,
    Simon

  4. #4
    aidan.heritage@virgin.net
    Guest

    Re: Copying Cell data and pasting into word document?

    Sorry about that - I'm used to working with open instances of Word, and
    loading templates, and then using one cell at a time with bookmarks in
    the template - revised and TESTED code is

    Dim appwd As Object
    On Error GoTo notloaded
    Set appwd = GetObject(, "Word.Application")
    notloaded:
    If Err.Number = 429 Then
    Set appwd = CreateObject("Word.Application")
    End If
    appwd.Visible = True
    On Error GoTo 0
    With appwd
    '.documents.Add
    Range("A1:B2").Copy 'replace A1:B2 with the range you want!
    .Selection.Paste
    End With


    Simon Lloyd wrote:
    > Hi Aidan thanks for the reply, i tried running the code in a seperate
    > module, and got the error "run time error '438' Object doesn't support
    > this property or method"
    >
    > Any ideas why this might be?, the code opened the Word window but no
    > document (no blank page).
    >
    > Regards,
    > Simon
    >
    >
    > --
    > Simon Lloyd
    > ------------------------------------------------------------------------
    > Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708
    > View this thread: http://www.excelforum.com/showthread...hreadid=549029



  5. #5
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    Thanks Aidan, worked a treat!

    Regards,
    Simon

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1