简体   繁体   中英

VBA - Copying the text and number formating in a ContentControl textbox in Word to Access

I'm trying to copy the text inside a contentcontrol textbox from a word document over to an ms access table. The issue with the script below is that it only copies the text and not the formatting.

I also need to copy if there's any numbering, bullet format, or tabs.

rst.Fields("Activity") = doc.ContentControls(10).Range.Text

I've been researching for a solution for days now and I can't seem to figure out how to copy the formatting as well.

Appreciate any help on this.

Thank you.

I may have found an alternative solution.
The only issue with this is that it doesn't capture the indentations.

doc.ContentControls(10).Copy
 rst.Fields("Activity") = Application.HtmlEncode(GetTextFromClipboard)

Function GetTextFromClipboard() As String
    Dim objClipboard As Object
    Set objClipboard = CreateObject("new:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
    objClipboard.GetFromClipboard
    GetTextFromClipboard = objClipboard.GetText
    Set objClipboard = Nothing
End Function

Any ideas on how to capture the indentations?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM