Keep formatting from excel to word in VBA

  • I'm trying to grab a cell in excel named "SiteNumber" that has a sentence in it and paste it into word at the bookmark "site_number".

    That is working.

    The issue is that there is one word in the sentence that is bolded and underlined. Is there a way to keep the formatting?

    Code is below. Thanks!

    Sub exporttoword()

    Application.ScreenUpdating = False

    Dim wordapp As New Word.Application

    Dim doc As Word.document

    Dim site_number As Word.Range

    Dim docpath As String

    wordapp.Visible = True

    Set doc = wordapp.Documents.Open([wordPath].Text, , True)


    Set site_number = doc.Bookmarks("site_number").Range

    site_number.Text = Range("SiteNumber").Value

    Application.ScreenUpdating = False

    Set site_number = Nothing

    Set doc = Nothing

    Application.ScreenUpdating = True

    End Sub

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!