Consulting

Results 1 to 3 of 3

Thread: Frm Word PasteSpecial

  1. #1
    VBAX Regular
    Joined
    Jan 2014
    Posts
    15
    Location

    Frm Word PasteSpecial

    Hi Guys,

    I have found the below code which opens a word doc and copies the text into an email.

    However, even though the default font in both Outlook and Word are set the same (Arial, 10pts) when pasting it changes it to the font to Calibri (Body), 11pts.

    Is there any way to correct this or an alternate routine?

    Sub CopyBodyFromWord()
    Dim oMailItem As Object
    Dim oWordApp As Object
    Dim oWordDoc As Object
    Dim oMailWordDoc As Object
    On Error GoTo CleanUp
    Set oWordApp = CreateObject("Word.Application")
    Set oWordDoc = oWordApp.Documents.Open("C:\Users\User\Desktop\Test.docx")
    oWordDoc.Content.Copy
    Set oMailItem = Application.CreateItem(0)
    With oMailItem
        .Display
    End With
    Set oMailWordDoc = Application.ActiveInspector.WordEditor
    oMailWordDoc.Application.Selection.Paste
    CleanUp:
    oWordApp.Quit
    Set oMailWordDoc = Nothing
    Set oMailItem = Nothing
    Set oWordDoc = Nothing
    Set oWordApp = Nothing
    
    End Sub
    Thanks in advance

  2. #2
    VBAX Mentor skatonni's Avatar
    Joined
    Jun 2006
    Posts
    347
    Location
    Try

    oMailWordDoc.Application.Selection.PasteAndFormat wdPasteDefault
    To debug, mouse-click anywhere in the code. Press F8 repeatedly to step through the code. http://www.cpearson.com/excel/DebuggingVBA.aspx

    If your problem has been solved in your thread, mark the thread "Solved" by going to the "Thread Tools" dropdown at the top of the thread. You might also consider rating the thread by going to the "Rate Thread" dropdown.

  3. #3
    VBAX Regular
    Joined
    Jan 2014
    Posts
    15
    Location
    Many thanks skatonni

Posting Permissions

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