Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Pasting contents of Word doc into Outlook

Discussion in 'Information Technology' started by N. Cotton, Jul 28, 2006.

  1. N. Cotton

    N. Cotton
    Expand Collapse
    Guest

    I am trying to paste the complete contents of a Word doc into a new Outlook
    message (yes using Access).

    Currently I open a new Outlook message instance, fill in the usual to:,
    subject: fields etc, then open a previously selected document in Word and
    select everything in the document using Set Rng = .Range().

    I would now like to paste the whole contents of the document (which are now
    in the clipboard) into the body of the outlook message. I am currently trying
    to paste them using sendkeys ^v, but depending on the sizoe of the document
    and delay etc it doesn't always paste it.

    Is there an easier or better way to acheieve this?

    Many thanks
     
  2. Loading...

    Similar Threads Forum Date
    Interfaith Materialists And Its Discontents Interfaith Dialogues Jun 10, 2016
    What is really in the contents of the Dasam Granth? Dasam Granth Jan 30, 2013
    DSM contents Dasam Granth Jul 29, 2011

  3. Rick B

    Rick B
    Expand Collapse
    Guest

    This is not a WORD or OUTLOOK newsgroup. This is an ACCESS newsgroup.

    Please post to a newsgroup related to the software you are using.

    --
    Rick B



    "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    news:75EB8912-2A8A-4F11-8E5F-E0B4A2DEB94C@microsoft.com...
    >I am trying to paste the complete contents of a Word doc into a new Outlook
    > message (yes using Access).
    >
    > Currently I open a new Outlook message instance, fill in the usual to:,
    > subject: fields etc, then open a previously selected document in Word and
    > select everything in the document using Set Rng = .Range().
    >
    > I would now like to paste the whole contents of the document (which are
    > now
    > in the clipboard) into the body of the outlook message. I am currently
    > trying
    > to paste them using sendkeys ^v, but depending on the sizoe of the
    > document
    > and delay etc it doesn't always paste it.
    >
    > Is there an easier or better way to acheieve this?
    >
    > Many thanks
    >
     
  4. N. Cotton

    N. Cotton
    Expand Collapse
    Guest

    As the message says, using Access!

    "Rick B" wrote:

    > This is not a WORD or OUTLOOK newsgroup. This is an ACCESS newsgroup.
    >
    > Please post to a newsgroup related to the software you are using.
    >
    > --
    > Rick B
    >
    >
    >
    > "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    > news:75EB8912-2A8A-4F11-8E5F-E0B4A2DEB94C@microsoft.com...
    > >I am trying to paste the complete contents of a Word doc into a new Outlook
    > > message (yes using Access).
    > >
    > > Currently I open a new Outlook message instance, fill in the usual to:,
    > > subject: fields etc, then open a previously selected document in Word and
    > > select everything in the document using Set Rng = .Range().
    > >
    > > I would now like to paste the whole contents of the document (which are
    > > now
    > > in the clipboard) into the body of the outlook message. I am currently
    > > trying
    > > to paste them using sendkeys ^v, but depending on the sizoe of the
    > > document
    > > and delay etc it doesn't always paste it.
    > >
    > > Is there an easier or better way to acheieve this?
    > >
    > > Many thanks
    > >

    >
    >
    >
     
  5. BruceM

    BruceM
    Expand Collapse
    Guest

    I think the question is about Access, even though it is not as clear as it
    might be about, for instance, the means of opening the "Outlook message
    instance".

    To NCotton, I cannot help you, but if you provide your code (or a simplified
    version of it) it would be more likely to attract the attention of somebody
    who can help.

    "Rick B" <Anonymous> wrote in message
    news:eWrQCalhGHA.1272@TK2MSFTNGP03.phx.gbl...
    > This is not a WORD or OUTLOOK newsgroup. This is an ACCESS newsgroup.
    >
    > Please post to a newsgroup related to the software you are using.
    >
    > --
    > Rick B
    >
    >
    >
    > "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    > news:75EB8912-2A8A-4F11-8E5F-E0B4A2DEB94C@microsoft.com...
    >>I am trying to paste the complete contents of a Word doc into a new
    >>Outlook
    >> message (yes using Access).
    >>
    >> Currently I open a new Outlook message instance, fill in the usual to:,
    >> subject: fields etc, then open a previously selected document in Word
    >> and
    >> select everything in the document using Set Rng = .Range().
    >>
    >> I would now like to paste the whole contents of the document (which are
    >> now
    >> in the clipboard) into the body of the outlook message. I am currently
    >> trying
    >> to paste them using sendkeys ^v, but depending on the sizoe of the
    >> document
    >> and delay etc it doesn't always paste it.
    >>
    >> Is there an easier or better way to acheieve this?
    >>
    >> Many thanks
    >>

    >
    >
     
  6. Rick B

    Rick B
    Expand Collapse
    Guest

    Sorry. My bad.

    --
    Rick B



    "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    news:E54FD6F7-A054-4354-BADF-BAEE7CD84BF5@microsoft.com...
    > As the message says, using Access!
    >
    > "Rick B" wrote:
    >
    >> This is not a WORD or OUTLOOK newsgroup. This is an ACCESS newsgroup.
    >>
    >> Please post to a newsgroup related to the software you are using.
    >>
    >> --
    >> Rick B
    >>
    >>
    >>
    >> "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    >> news:75EB8912-2A8A-4F11-8E5F-E0B4A2DEB94C@microsoft.com...
    >> >I am trying to paste the complete contents of a Word doc into a new
    >> >Outlook
    >> > message (yes using Access).
    >> >
    >> > Currently I open a new Outlook message instance, fill in the usual to:,
    >> > subject: fields etc, then open a previously selected document in Word
    >> > and
    >> > select everything in the document using Set Rng = .Range().
    >> >
    >> > I would now like to paste the whole contents of the document (which are
    >> > now
    >> > in the clipboard) into the body of the outlook message. I am currently
    >> > trying
    >> > to paste them using sendkeys ^v, but depending on the sizoe of the
    >> > document
    >> > and delay etc it doesn't always paste it.
    >> >
    >> > Is there an easier or better way to acheieve this?
    >> >
    >> > Many thanks
    >> >

    >>
    >>
    >>
     
  7. N. Cotton

    N. Cotton
    Expand Collapse
    Guest

    Apologies for that - it obviously should have been clearer.

    This is the code I use to create a new Outlook message...

    Dim objOutlook As Object
    Set objOutlook = GetObject(, "Outlook.Application")
    If Err.Number <> 0 Then
    Set objOutlook = CreateObject("Outlook.Application")
    Err.Clear
    End If

    Dim objOutlookMsg As Object

    Set objOutlookMsg = objOutlook.CreateItem(0)

    With objOutlookMsg
    .To = "firstrecipient@me.com"
    .BCC = Me.txtbcc
    .Subject = strSubject
    .Display
    .Attachments.Add (Me.txtAttachmentDocument)
    DoEvents
    SendKeys "^v"
    DoEvents
    End With

    Basically all I require is something better to replace the Sendkeys "^v" to
    paste the contents of the clipboard (previously copied from a Word doc) into
    the .body of the message.

    Not sure how relevant it is, but this is the code I use to get the word
    document contents:

    Set appWord = GetObject(, "Word.application")
    bolWordAlreadyOpen = True
    If Err <> 0 Then
    Set appWord = CreateObject("Word.application")
    bolWordAlreadyOpen = False
    Err.Clear
    End If

    Dim strDoc As String
    strDoc = Nz(Me.txtPasteDocument)

    With appWord
    Set doc = .Documents.Open(strDoc)
    '.Visible = True
    With doc
    .Activate
    DoEvents
    Set Rng = .Range()
    Rng.Select
    Rng.Copy
    DoEvents

    This selects everything in the document and copies it to the clipboard.



    "BruceM" wrote:

    > I think the question is about Access, even though it is not as clear as it
    > might be about, for instance, the means of opening the "Outlook message
    > instance".
    >
    > To NCotton, I cannot help you, but if you provide your code (or a simplified
    > version of it) it would be more likely to attract the attention of somebody
    > who can help.
    >
    > "Rick B" <Anonymous> wrote in message
    > news:eWrQCalhGHA.1272@TK2MSFTNGP03.phx.gbl...
    > > This is not a WORD or OUTLOOK newsgroup. This is an ACCESS newsgroup.
    > >
    > > Please post to a newsgroup related to the software you are using.
    > >
    > > --
    > > Rick B
    > >
    > >
    > >
    > > "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    > > news:75EB8912-2A8A-4F11-8E5F-E0B4A2DEB94C@microsoft.com...
    > >>I am trying to paste the complete contents of a Word doc into a new
    > >>Outlook
    > >> message (yes using Access).
    > >>
    > >> Currently I open a new Outlook message instance, fill in the usual to:,
    > >> subject: fields etc, then open a previously selected document in Word
    > >> and
    > >> select everything in the document using Set Rng = .Range().
    > >>
    > >> I would now like to paste the whole contents of the document (which are
    > >> now
    > >> in the clipboard) into the body of the outlook message. I am currently
    > >> trying
    > >> to paste them using sendkeys ^v, but depending on the sizoe of the
    > >> document
    > >> and delay etc it doesn't always paste it.
    > >>
    > >> Is there an easier or better way to acheieve this?
    > >>
    > >> Many thanks
    > >>

    > >
    > >

    >
    >
    >
     
  8. BruceM

    BruceM
    Expand Collapse
    Guest

    The reason I said I can't help you is that I don't know enough about using
    VBA for this purpose. Perhaps somebody else will jump in.

    "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    news:0520AE45-62FA-4784-8077-FEA240DA6B4A@microsoft.com...
    > Apologies for that - it obviously should have been clearer.
    >
    > This is the code I use to create a new Outlook message...
    >
    > Dim objOutlook As Object
    > Set objOutlook = GetObject(, "Outlook.Application")
    > If Err.Number <> 0 Then
    > Set objOutlook = CreateObject("Outlook.Application")
    > Err.Clear
    > End If
    >
    > Dim objOutlookMsg As Object
    >
    > Set objOutlookMsg = objOutlook.CreateItem(0)
    >
    > With objOutlookMsg
    > .To = "firstrecipient@me.com"
    > .BCC = Me.txtbcc
    > .Subject = strSubject
    > .Display
    > .Attachments.Add (Me.txtAttachmentDocument)
    > DoEvents
    > SendKeys "^v"
    > DoEvents
    > End With
    >
    > Basically all I require is something better to replace the Sendkeys "^v"
    > to
    > paste the contents of the clipboard (previously copied from a Word doc)
    > into
    > the .body of the message.
    >
    > Not sure how relevant it is, but this is the code I use to get the word
    > document contents:
    >
    > Set appWord = GetObject(, "Word.application")
    > bolWordAlreadyOpen = True
    > If Err <> 0 Then
    > Set appWord = CreateObject("Word.application")
    > bolWordAlreadyOpen = False
    > Err.Clear
    > End If
    >
    > Dim strDoc As String
    > strDoc = Nz(Me.txtPasteDocument)
    >
    > With appWord
    > Set doc = .Documents.Open(strDoc)
    > '.Visible = True
    > With doc
    > .Activate
    > DoEvents
    > Set Rng = .Range()
    > Rng.Select
    > Rng.Copy
    > DoEvents
    >
    > This selects everything in the document and copies it to the clipboard.
    >
    >
    >
    > "BruceM" wrote:
    >
    >> I think the question is about Access, even though it is not as clear as
    >> it
    >> might be about, for instance, the means of opening the "Outlook message
    >> instance".
    >>
    >> To NCotton, I cannot help you, but if you provide your code (or a
    >> simplified
    >> version of it) it would be more likely to attract the attention of
    >> somebody
    >> who can help.
    >>
    >> "Rick B" <Anonymous> wrote in message
    >> news:eWrQCalhGHA.1272@TK2MSFTNGP03.phx.gbl...
    >> > This is not a WORD or OUTLOOK newsgroup. This is an ACCESS newsgroup.
    >> >
    >> > Please post to a newsgroup related to the software you are using.
    >> >
    >> > --
    >> > Rick B
    >> >
    >> >
    >> >
    >> > "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    >> > news:75EB8912-2A8A-4F11-8E5F-E0B4A2DEB94C@microsoft.com...
    >> >>I am trying to paste the complete contents of a Word doc into a new
    >> >>Outlook
    >> >> message (yes using Access).
    >> >>
    >> >> Currently I open a new Outlook message instance, fill in the usual
    >> >> to:,
    >> >> subject: fields etc, then open a previously selected document in Word
    >> >> and
    >> >> select everything in the document using Set Rng = .Range().
    >> >>
    >> >> I would now like to paste the whole contents of the document (which
    >> >> are
    >> >> now
    >> >> in the clipboard) into the body of the outlook message. I am currently
    >> >> trying
    >> >> to paste them using sendkeys ^v, but depending on the sizoe of the
    >> >> document
    >> >> and delay etc it doesn't always paste it.
    >> >>
    >> >> Is there an easier or better way to acheieve this?
    >> >>
    >> >> Many thanks
    >> >>
    >> >
    >> >

    >>
    >>
    >>
     
  9. Michael H

    Michael H
    Expand Collapse
    Guest

    Hi.

    I don't use Outlook for e-mail, so I can't help you directly. However, you
    may be able to find something useful here:
    http://www.granite.ab.ca/access/email

    Additionally, the use of SendKeys is normally considered something to be
    avoided. You may benefit from using this Replacement for SendKeys:
    http://www.mvps.org/access/api/api0046.htm

    -Michael


    "N. Cotton" wrote:

    > I am trying to paste the complete contents of a Word doc into a new Outlook
    > message (yes using Access).
    >
    > Currently I open a new Outlook message instance, fill in the usual to:,
    > subject: fields etc, then open a previously selected document in Word and
    > select everything in the document using Set Rng = .Range().
    >
    > I would now like to paste the whole contents of the document (which are now
    > in the clipboard) into the body of the outlook message. I am currently trying
    > to paste them using sendkeys ^v, but depending on the sizoe of the document
    > and delay etc it doesn't always paste it.
    >
    > Is there an easier or better way to acheieve this?
    >
    > Many thanks
    >
     
  10. Douglas J. Steele

    Douglas J. Steele
    Expand Collapse
    Guest

    See whether you can utilized the code in
    http://support.microsoft.com/?id=138910 (and
    http://support.microsoft.com/?id=138909, for that matter) to work with the
    clipboard. (Don't worry that the articles only mention Access 95 and 97: it
    applies to all versions since as well)

    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no private e-mails, please)


    "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    news:0520AE45-62FA-4784-8077-FEA240DA6B4A@microsoft.com...
    > Apologies for that - it obviously should have been clearer.
    >
    > This is the code I use to create a new Outlook message...
    >
    > Dim objOutlook As Object
    > Set objOutlook = GetObject(, "Outlook.Application")
    > If Err.Number <> 0 Then
    > Set objOutlook = CreateObject("Outlook.Application")
    > Err.Clear
    > End If
    >
    > Dim objOutlookMsg As Object
    >
    > Set objOutlookMsg = objOutlook.CreateItem(0)
    >
    > With objOutlookMsg
    > .To = "firstrecipient@me.com"
    > .BCC = Me.txtbcc
    > .Subject = strSubject
    > .Display
    > .Attachments.Add (Me.txtAttachmentDocument)
    > DoEvents
    > SendKeys "^v"
    > DoEvents
    > End With
    >
    > Basically all I require is something better to replace the Sendkeys "^v"
    > to
    > paste the contents of the clipboard (previously copied from a Word doc)
    > into
    > the .body of the message.
    >
    > Not sure how relevant it is, but this is the code I use to get the word
    > document contents:
    >
    > Set appWord = GetObject(, "Word.application")
    > bolWordAlreadyOpen = True
    > If Err <> 0 Then
    > Set appWord = CreateObject("Word.application")
    > bolWordAlreadyOpen = False
    > Err.Clear
    > End If
    >
    > Dim strDoc As String
    > strDoc = Nz(Me.txtPasteDocument)
    >
    > With appWord
    > Set doc = .Documents.Open(strDoc)
    > '.Visible = True
    > With doc
    > .Activate
    > DoEvents
    > Set Rng = .Range()
    > Rng.Select
    > Rng.Copy
    > DoEvents
    >
    > This selects everything in the document and copies it to the clipboard.
    >
    >
    >
    > "BruceM" wrote:
    >
    >> I think the question is about Access, even though it is not as clear as
    >> it
    >> might be about, for instance, the means of opening the "Outlook message
    >> instance".
    >>
    >> To NCotton, I cannot help you, but if you provide your code (or a
    >> simplified
    >> version of it) it would be more likely to attract the attention of
    >> somebody
    >> who can help.
    >>
    >> "Rick B" <Anonymous> wrote in message
    >> news:eWrQCalhGHA.1272@TK2MSFTNGP03.phx.gbl...
    >> > This is not a WORD or OUTLOOK newsgroup. This is an ACCESS newsgroup.
    >> >
    >> > Please post to a newsgroup related to the software you are using.
    >> >
    >> > --
    >> > Rick B
    >> >
    >> >
    >> >
    >> > "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    >> > news:75EB8912-2A8A-4F11-8E5F-E0B4A2DEB94C@microsoft.com...
    >> >>I am trying to paste the complete contents of a Word doc into a new
    >> >>Outlook
    >> >> message (yes using Access).
    >> >>
    >> >> Currently I open a new Outlook message instance, fill in the usual
    >> >> to:,
    >> >> subject: fields etc, then open a previously selected document in Word
    >> >> and
    >> >> select everything in the document using Set Rng = .Range().
    >> >>
    >> >> I would now like to paste the whole contents of the document (which
    >> >> are
    >> >> now
    >> >> in the clipboard) into the body of the outlook message. I am currently
    >> >> trying
    >> >> to paste them using sendkeys ^v, but depending on the sizoe of the
    >> >> document
    >> >> and delay etc it doesn't always paste it.
    >> >>
    >> >> Is there an easier or better way to acheieve this?
    >> >>
    >> >> Many thanks
    >> >>
    >> >
    >> >

    >>
    >>
    >>
     
  11. Larry Kahm

    Larry Kahm
    Expand Collapse
    Guest

    Here's a possible solution - I haven't coded it, but it should work.

    Once you have your Rng.Select, you can then just use the text you selected:

    Dim strSelectedText as String

    Rng.Select
    strSelectedText = Selection.Text

    There should be no need to copy the text to the clipboard (which obviatest
    the need to paste it).

    Then, in your e-mail, use:

    ..Body = strSelectedText

    Hope that helps!

    Larry


    "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    news:0520AE45-62FA-4784-8077-FEA240DA6B4A@microsoft.com...
    > Apologies for that - it obviously should have been clearer.
    >
    > This is the code I use to create a new Outlook message...
    >
    > Dim objOutlook As Object
    > Set objOutlook = GetObject(, "Outlook.Application")
    > If Err.Number <> 0 Then
    > Set objOutlook = CreateObject("Outlook.Application")
    > Err.Clear
    > End If
    >
    > Dim objOutlookMsg As Object
    >
    > Set objOutlookMsg = objOutlook.CreateItem(0)
    >
    > With objOutlookMsg
    > .To = "firstrecipient@me.com"
    > .BCC = Me.txtbcc
    > .Subject = strSubject
    > .Display
    > .Attachments.Add (Me.txtAttachmentDocument)
    > DoEvents
    > SendKeys "^v"
    > DoEvents
    > End With
    >
    > Basically all I require is something better to replace the Sendkeys "^v"
    > to
    > paste the contents of the clipboard (previously copied from a Word doc)
    > into
    > the .body of the message.
    >
    > Not sure how relevant it is, but this is the code I use to get the word
    > document contents:
    >
    > Set appWord = GetObject(, "Word.application")
    > bolWordAlreadyOpen = True
    > If Err <> 0 Then
    > Set appWord = CreateObject("Word.application")
    > bolWordAlreadyOpen = False
    > Err.Clear
    > End If
    >
    > Dim strDoc As String
    > strDoc = Nz(Me.txtPasteDocument)
    >
    > With appWord
    > Set doc = .Documents.Open(strDoc)
    > '.Visible = True
    > With doc
    > .Activate
    > DoEvents
    > Set Rng = .Range()
    > Rng.Select
    > Rng.Copy
    > DoEvents
    >
    > This selects everything in the document and copies it to the clipboard.
    >
    >
    >
    > "BruceM" wrote:
    >
    >> I think the question is about Access, even though it is not as clear as
    >> it
    >> might be about, for instance, the means of opening the "Outlook message
    >> instance".
    >>
    >> To NCotton, I cannot help you, but if you provide your code (or a
    >> simplified
    >> version of it) it would be more likely to attract the attention of
    >> somebody
    >> who can help.
    >>
    >> "Rick B" <Anonymous> wrote in message
    >> news:eWrQCalhGHA.1272@TK2MSFTNGP03.phx.gbl...
    >> > This is not a WORD or OUTLOOK newsgroup. This is an ACCESS newsgroup.
    >> >
    >> > Please post to a newsgroup related to the software you are using.
    >> >
    >> > --
    >> > Rick B
    >> >
    >> >
    >> >
    >> > "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    >> > news:75EB8912-2A8A-4F11-8E5F-E0B4A2DEB94C@microsoft.com...
    >> >>I am trying to paste the complete contents of a Word doc into a new
    >> >>Outlook
    >> >> message (yes using Access).
    >> >>
    >> >> Currently I open a new Outlook message instance, fill in the usual
    >> >> to:,
    >> >> subject: fields etc, then open a previously selected document in Word
    >> >> and
    >> >> select everything in the document using Set Rng = .Range().
    >> >>
    >> >> I would now like to paste the whole contents of the document (which
    >> >> are
    >> >> now
    >> >> in the clipboard) into the body of the outlook message. I am currently
    >> >> trying
    >> >> to paste them using sendkeys ^v, but depending on the sizoe of the
    >> >> document
    >> >> and delay etc it doesn't always paste it.
    >> >>
    >> >> Is there an easier or better way to acheieve this?
    >> >>
    >> >> Many thanks
    >> >>
    >> >
    >> >

    >>
    >>
    >>
     
  12. N. Cotton

    N. Cotton
    Expand Collapse
    Guest

    Thanks a lot for this and it works perfectly if the document contains only
    text.

    Unfortunately it can also contain tables and images.

    Is there a similar way to select everything rather than just text?

    Many thanks again.

    "Larry Kahm" wrote:

    > Here's a possible solution - I haven't coded it, but it should work.
    >
    > Once you have your Rng.Select, you can then just use the text you selected:
    >
    > Dim strSelectedText as String
    >
    > Rng.Select
    > strSelectedText = Selection.Text
    >
    > There should be no need to copy the text to the clipboard (which obviatest
    > the need to paste it).
    >
    > Then, in your e-mail, use:
    >
    > ..Body = strSelectedText
    >
    > Hope that helps!
    >
    > Larry
    >
    >
    > "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    > news:0520AE45-62FA-4784-8077-FEA240DA6B4A@microsoft.com...
    > > Apologies for that - it obviously should have been clearer.
    > >
    > > This is the code I use to create a new Outlook message...
    > >
    > > Dim objOutlook As Object
    > > Set objOutlook = GetObject(, "Outlook.Application")
    > > If Err.Number <> 0 Then
    > > Set objOutlook = CreateObject("Outlook.Application")
    > > Err.Clear
    > > End If
    > >
    > > Dim objOutlookMsg As Object
    > >
    > > Set objOutlookMsg = objOutlook.CreateItem(0)
    > >
    > > With objOutlookMsg
    > > .To = "firstrecipient@me.com"
    > > .BCC = Me.txtbcc
    > > .Subject = strSubject
    > > .Display
    > > .Attachments.Add (Me.txtAttachmentDocument)
    > > DoEvents
    > > SendKeys "^v"
    > > DoEvents
    > > End With
    > >
    > > Basically all I require is something better to replace the Sendkeys "^v"
    > > to
    > > paste the contents of the clipboard (previously copied from a Word doc)
    > > into
    > > the .body of the message.
    > >
    > > Not sure how relevant it is, but this is the code I use to get the word
    > > document contents:
    > >
    > > Set appWord = GetObject(, "Word.application")
    > > bolWordAlreadyOpen = True
    > > If Err <> 0 Then
    > > Set appWord = CreateObject("Word.application")
    > > bolWordAlreadyOpen = False
    > > Err.Clear
    > > End If
    > >
    > > Dim strDoc As String
    > > strDoc = Nz(Me.txtPasteDocument)
    > >
    > > With appWord
    > > Set doc = .Documents.Open(strDoc)
    > > '.Visible = True
    > > With doc
    > > .Activate
    > > DoEvents
    > > Set Rng = .Range()
    > > Rng.Select
    > > Rng.Copy
    > > DoEvents
    > >
    > > This selects everything in the document and copies it to the clipboard.
    > >
    > >
    > >
    > > "BruceM" wrote:
    > >
    > >> I think the question is about Access, even though it is not as clear as
    > >> it
    > >> might be about, for instance, the means of opening the "Outlook message
    > >> instance".
    > >>
    > >> To NCotton, I cannot help you, but if you provide your code (or a
    > >> simplified
    > >> version of it) it would be more likely to attract the attention of
    > >> somebody
    > >> who can help.
    > >>
    > >> "Rick B" <Anonymous> wrote in message
    > >> news:eWrQCalhGHA.1272@TK2MSFTNGP03.phx.gbl...
    > >> > This is not a WORD or OUTLOOK newsgroup. This is an ACCESS newsgroup.
    > >> >
    > >> > Please post to a newsgroup related to the software you are using.
    > >> >
    > >> > --
    > >> > Rick B
    > >> >
    > >> >
    > >> >
    > >> > "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    > >> > news:75EB8912-2A8A-4F11-8E5F-E0B4A2DEB94C@microsoft.com...
    > >> >>I am trying to paste the complete contents of a Word doc into a new
    > >> >>Outlook
    > >> >> message (yes using Access).
    > >> >>
    > >> >> Currently I open a new Outlook message instance, fill in the usual
    > >> >> to:,
    > >> >> subject: fields etc, then open a previously selected document in Word
    > >> >> and
    > >> >> select everything in the document using Set Rng = .Range().
    > >> >>
    > >> >> I would now like to paste the whole contents of the document (which
    > >> >> are
    > >> >> now
    > >> >> in the clipboard) into the body of the outlook message. I am currently
    > >> >> trying
    > >> >> to paste them using sendkeys ^v, but depending on the sizoe of the
    > >> >> document
    > >> >> and delay etc it doesn't always paste it.
    > >> >>
    > >> >> Is there an easier or better way to acheieve this?
    > >> >>
    > >> >> Many thanks
    > >> >>
    > >> >
    > >> >
    > >>
    > >>
    > >>

    >
    >
    >
     
  13. N. Cotton

    N. Cotton
    Expand Collapse
    Guest

    Thanks everyone for the replies.

    The solutions from Larry and Douglas work great if the document only
    contains text. The problem is that the doc can be a mixture of text, images
    and tables.

    Any suggestions how to amend these to contain every type?


    Larry: thanks for that, the alternative to sendkeys presents me with the
    same problem. Depending on the length of time it takes to copy and or paste
    the contents. It sometimes works and sometimes doesn't.



    "N. Cotton" wrote:

    > I am trying to paste the complete contents of a Word doc into a new Outlook
    > message (yes using Access).
    >
    > Currently I open a new Outlook message instance, fill in the usual to:,
    > subject: fields etc, then open a previously selected document in Word and
    > select everything in the document using Set Rng = .Range().
    >
    > I would now like to paste the whole contents of the document (which are now
    > in the clipboard) into the body of the outlook message. I am currently trying
    > to paste them using sendkeys ^v, but depending on the sizoe of the document
    > and delay etc it doesn't always paste it.
    >
    > Is there an easier or better way to acheieve this?
    >
    > Many thanks
    >
     
  14. Larry Kahm

    Larry Kahm
    Expand Collapse
    Guest

    I'm not a Word expert; in fact, I'm learning how to take what's in OLE
    objects and put them in their correct fields for one of my client's
    databases.

    It's possible that Selection is more encompassing than Range for what you
    want accomplish. I suggest you open Word and go to Tools, Macro, Visual
    Basic Editor and then click Help. Research the Selection object - I think
    that should solve your problem.

    Larry

    "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    news:03746C97-90EE-48AA-9121-978025BCD35A@microsoft.com...
    > Thanks a lot for this and it works perfectly if the document contains only
    > text.
    >
    > Unfortunately it can also contain tables and images.
    >
    > Is there a similar way to select everything rather than just text?
    >
    > Many thanks again.
    >
    > "Larry Kahm" wrote:
    >
    >> Here's a possible solution - I haven't coded it, but it should work.
    >>
    >> Once you have your Rng.Select, you can then just use the text you
    >> selected:
    >>
    >> Dim strSelectedText as String
    >>
    >> Rng.Select
    >> strSelectedText = Selection.Text
    >>
    >> There should be no need to copy the text to the clipboard (which
    >> obviatest
    >> the need to paste it).
    >>
    >> Then, in your e-mail, use:
    >>
    >> ..Body = strSelectedText
    >>
    >> Hope that helps!
    >>
    >> Larry
    >>
    >>
    >> "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    >> news:0520AE45-62FA-4784-8077-FEA240DA6B4A@microsoft.com...
    >> > Apologies for that - it obviously should have been clearer.
    >> >
    >> > This is the code I use to create a new Outlook message...
    >> >
    >> > Dim objOutlook As Object
    >> > Set objOutlook = GetObject(, "Outlook.Application")
    >> > If Err.Number <> 0 Then
    >> > Set objOutlook = CreateObject("Outlook.Application")
    >> > Err.Clear
    >> > End If
    >> >
    >> > Dim objOutlookMsg As Object
    >> >
    >> > Set objOutlookMsg = objOutlook.CreateItem(0)
    >> >
    >> > With objOutlookMsg
    >> > .To = "firstrecipient@me.com"
    >> > .BCC = Me.txtbcc
    >> > .Subject = strSubject
    >> > .Display
    >> > .Attachments.Add (Me.txtAttachmentDocument)
    >> > DoEvents
    >> > SendKeys "^v"
    >> > DoEvents
    >> > End With
    >> >
    >> > Basically all I require is something better to replace the Sendkeys
    >> > "^v"
    >> > to
    >> > paste the contents of the clipboard (previously copied from a Word doc)
    >> > into
    >> > the .body of the message.
    >> >
    >> > Not sure how relevant it is, but this is the code I use to get the word
    >> > document contents:
    >> >
    >> > Set appWord = GetObject(, "Word.application")
    >> > bolWordAlreadyOpen = True
    >> > If Err <> 0 Then
    >> > Set appWord = CreateObject("Word.application")
    >> > bolWordAlreadyOpen = False
    >> > Err.Clear
    >> > End If
    >> >
    >> > Dim strDoc As String
    >> > strDoc = Nz(Me.txtPasteDocument)
    >> >
    >> > With appWord
    >> > Set doc = .Documents.Open(strDoc)
    >> > '.Visible = True
    >> > With doc
    >> > .Activate
    >> > DoEvents
    >> > Set Rng = .Range()
    >> > Rng.Select
    >> > Rng.Copy
    >> > DoEvents
    >> >
    >> > This selects everything in the document and copies it to the clipboard.
    >> >
    >> >
    >> >
    >> > "BruceM" wrote:
    >> >
    >> >> I think the question is about Access, even though it is not as clear
    >> >> as
    >> >> it
    >> >> might be about, for instance, the means of opening the "Outlook
    >> >> message
    >> >> instance".
    >> >>
    >> >> To NCotton, I cannot help you, but if you provide your code (or a
    >> >> simplified
    >> >> version of it) it would be more likely to attract the attention of
    >> >> somebody
    >> >> who can help.
    >> >>
    >> >> "Rick B" <Anonymous> wrote in message
    >> >> news:eWrQCalhGHA.1272@TK2MSFTNGP03.phx.gbl...
    >> >> > This is not a WORD or OUTLOOK newsgroup. This is an ACCESS
    >> >> > newsgroup.
    >> >> >
    >> >> > Please post to a newsgroup related to the software you are using.
    >> >> >
    >> >> > --
    >> >> > Rick B
    >> >> >
    >> >> >
    >> >> >
    >> >> > "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    >> >> > news:75EB8912-2A8A-4F11-8E5F-E0B4A2DEB94C@microsoft.com...
    >> >> >>I am trying to paste the complete contents of a Word doc into a new
    >> >> >>Outlook
    >> >> >> message (yes using Access).
    >> >> >>
    >> >> >> Currently I open a new Outlook message instance, fill in the usual
    >> >> >> to:,
    >> >> >> subject: fields etc, then open a previously selected document in
    >> >> >> Word
    >> >> >> and
    >> >> >> select everything in the document using Set Rng = .Range().
    >> >> >>
    >> >> >> I would now like to paste the whole contents of the document (which
    >> >> >> are
    >> >> >> now
    >> >> >> in the clipboard) into the body of the outlook message. I am
    >> >> >> currently
    >> >> >> trying
    >> >> >> to paste them using sendkeys ^v, but depending on the sizoe of the
    >> >> >> document
    >> >> >> and delay etc it doesn't always paste it.
    >> >> >>
    >> >> >> Is there an easier or better way to acheieve this?
    >> >> >>
    >> >> >> Many thanks
    >> >> >>
    >> >> >
    >> >> >
    >> >>
    >> >>
    >> >>

    >>
    >>
    >>
     
  15. Larry Kahm

    Larry Kahm
    Expand Collapse
    Guest

    Selection.WholeStory

    Will get the entire document (equivalent of Ctrl+A). The copy/paste timing
    issue might be corrected by removing the DoEvents code (I'm not sure why you
    are using it).

    Larry

    "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    news:77CDA582-4027-4C03-B9B5-033C0E48DD0A@microsoft.com...
    > Thanks everyone for the replies.
    >
    > The solutions from Larry and Douglas work great if the document only
    > contains text. The problem is that the doc can be a mixture of text,
    > images
    > and tables.
    >
    > Any suggestions how to amend these to contain every type?
    >
    >
    > Larry: thanks for that, the alternative to sendkeys presents me with the
    > same problem. Depending on the length of time it takes to copy and or
    > paste
    > the contents. It sometimes works and sometimes doesn't.
    >
    >
    >
    > "N. Cotton" wrote:
    >
    >> I am trying to paste the complete contents of a Word doc into a new
    >> Outlook
    >> message (yes using Access).
    >>
    >> Currently I open a new Outlook message instance, fill in the usual to:,
    >> subject: fields etc, then open a previously selected document in Word
    >> and
    >> select everything in the document using Set Rng = .Range().
    >>
    >> I would now like to paste the whole contents of the document (which are
    >> now
    >> in the clipboard) into the body of the outlook message. I am currently
    >> trying
    >> to paste them using sendkeys ^v, but depending on the sizoe of the
    >> document
    >> and delay etc it doesn't always paste it.
    >>
    >> Is there an easier or better way to acheieve this?
    >>
    >> Many thanks
    >>
     
  16. Douglas J Steele

    Douglas J Steele
    Expand Collapse
    Guest

    Despite the fact that you're using Access to automate this, you'd probably
    be better off asking in a newsgroup related to Word or Outlook. Remember
    that Automation uses the commands of the application that's being automated,
    not of the application that's running the automation.

    --
    Doug Steele, Microsoft Access MVP
    http://I.Am/DougSteele
    (no e-mails, please!)


    "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    news:77CDA582-4027-4C03-B9B5-033C0E48DD0A@microsoft.com...
    > Thanks everyone for the replies.
    >
    > The solutions from Larry and Douglas work great if the document only
    > contains text. The problem is that the doc can be a mixture of text,

    images
    > and tables.
    >
    > Any suggestions how to amend these to contain every type?
    >
    >
    > Larry: thanks for that, the alternative to sendkeys presents me with the
    > same problem. Depending on the length of time it takes to copy and or

    paste
    > the contents. It sometimes works and sometimes doesn't.
    >
    >
    >
    > "N. Cotton" wrote:
    >
    > > I am trying to paste the complete contents of a Word doc into a new

    Outlook
    > > message (yes using Access).
    > >
    > > Currently I open a new Outlook message instance, fill in the usual to:,
    > > subject: fields etc, then open a previously selected document in Word

    and
    > > select everything in the document using Set Rng = .Range().
    > >
    > > I would now like to paste the whole contents of the document (which are

    now
    > > in the clipboard) into the body of the outlook message. I am currently

    trying
    > > to paste them using sendkeys ^v, but depending on the sizoe of the

    document
    > > and delay etc it doesn't always paste it.
    > >
    > > Is there an easier or better way to acheieve this?
    > >
    > > Many thanks
    > >
     
  17. BruceM

    BruceM
    Expand Collapse
    Guest

    You also need to make sure, if it is possible to include things other than
    text in the copy and paste operation, that e-mail recipients can receive
    things other than plain text. Many people opt for text-only e-mails.

    "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    news:03746C97-90EE-48AA-9121-978025BCD35A@microsoft.com...
    > Thanks a lot for this and it works perfectly if the document contains only
    > text.
    >
    > Unfortunately it can also contain tables and images.
    >
    > Is there a similar way to select everything rather than just text?
    >
    > Many thanks again.
    >
    > "Larry Kahm" wrote:
    >
    >> Here's a possible solution - I haven't coded it, but it should work.
    >>
    >> Once you have your Rng.Select, you can then just use the text you
    >> selected:
    >>
    >> Dim strSelectedText as String
    >>
    >> Rng.Select
    >> strSelectedText = Selection.Text
    >>
    >> There should be no need to copy the text to the clipboard (which
    >> obviatest
    >> the need to paste it).
    >>
    >> Then, in your e-mail, use:
    >>
    >> ..Body = strSelectedText
    >>
    >> Hope that helps!
    >>
    >> Larry
    >>
    >>
    >> "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    >> news:0520AE45-62FA-4784-8077-FEA240DA6B4A@microsoft.com...
    >> > Apologies for that - it obviously should have been clearer.
    >> >
    >> > This is the code I use to create a new Outlook message...
    >> >
    >> > Dim objOutlook As Object
    >> > Set objOutlook = GetObject(, "Outlook.Application")
    >> > If Err.Number <> 0 Then
    >> > Set objOutlook = CreateObject("Outlook.Application")
    >> > Err.Clear
    >> > End If
    >> >
    >> > Dim objOutlookMsg As Object
    >> >
    >> > Set objOutlookMsg = objOutlook.CreateItem(0)
    >> >
    >> > With objOutlookMsg
    >> > .To = "firstrecipient@me.com"
    >> > .BCC = Me.txtbcc
    >> > .Subject = strSubject
    >> > .Display
    >> > .Attachments.Add (Me.txtAttachmentDocument)
    >> > DoEvents
    >> > SendKeys "^v"
    >> > DoEvents
    >> > End With
    >> >
    >> > Basically all I require is something better to replace the Sendkeys
    >> > "^v"
    >> > to
    >> > paste the contents of the clipboard (previously copied from a Word doc)
    >> > into
    >> > the .body of the message.
    >> >
    >> > Not sure how relevant it is, but this is the code I use to get the word
    >> > document contents:
    >> >
    >> > Set appWord = GetObject(, "Word.application")
    >> > bolWordAlreadyOpen = True
    >> > If Err <> 0 Then
    >> > Set appWord = CreateObject("Word.application")
    >> > bolWordAlreadyOpen = False
    >> > Err.Clear
    >> > End If
    >> >
    >> > Dim strDoc As String
    >> > strDoc = Nz(Me.txtPasteDocument)
    >> >
    >> > With appWord
    >> > Set doc = .Documents.Open(strDoc)
    >> > '.Visible = True
    >> > With doc
    >> > .Activate
    >> > DoEvents
    >> > Set Rng = .Range()
    >> > Rng.Select
    >> > Rng.Copy
    >> > DoEvents
    >> >
    >> > This selects everything in the document and copies it to the clipboard.
    >> >
    >> >
    >> >
    >> > "BruceM" wrote:
    >> >
    >> >> I think the question is about Access, even though it is not as clear
    >> >> as
    >> >> it
    >> >> might be about, for instance, the means of opening the "Outlook
    >> >> message
    >> >> instance".
    >> >>
    >> >> To NCotton, I cannot help you, but if you provide your code (or a
    >> >> simplified
    >> >> version of it) it would be more likely to attract the attention of
    >> >> somebody
    >> >> who can help.
    >> >>
    >> >> "Rick B" <Anonymous> wrote in message
    >> >> news:eWrQCalhGHA.1272@TK2MSFTNGP03.phx.gbl...
    >> >> > This is not a WORD or OUTLOOK newsgroup. This is an ACCESS
    >> >> > newsgroup.
    >> >> >
    >> >> > Please post to a newsgroup related to the software you are using.
    >> >> >
    >> >> > --
    >> >> > Rick B
    >> >> >
    >> >> >
    >> >> >
    >> >> > "N. Cotton" <NCotton@discussions.microsoft.com> wrote in message
    >> >> > news:75EB8912-2A8A-4F11-8E5F-E0B4A2DEB94C@microsoft.com...
    >> >> >>I am trying to paste the complete contents of a Word doc into a new
    >> >> >>Outlook
    >> >> >> message (yes using Access).
    >> >> >>
    >> >> >> Currently I open a new Outlook message instance, fill in the usual
    >> >> >> to:,
    >> >> >> subject: fields etc, then open a previously selected document in
    >> >> >> Word
    >> >> >> and
    >> >> >> select everything in the document using Set Rng = .Range().
    >> >> >>
    >> >> >> I would now like to paste the whole contents of the document (which
    >> >> >> are
    >> >> >> now
    >> >> >> in the clipboard) into the body of the outlook message. I am
    >> >> >> currently
    >> >> >> trying
    >> >> >> to paste them using sendkeys ^v, but depending on the sizoe of the
    >> >> >> document
    >> >> >> and delay etc it doesn't always paste it.
    >> >> >>
    >> >> >> Is there an easier or better way to acheieve this?
    >> >> >>
    >> >> >> Many thanks
    >> >> >>
    >> >> >
    >> >> >
    >> >>
    >> >>
    >> >>

    >>
    >>
    >>
     

Share This Page