I have formatted cells that I wish to copy and paste into an html form.
I need a way to copy the range to clipboard and retain the formatting. Since from Word it works, that's where I'm starting... but if there is another way...
I'm thinking of either an embed word file, or a hidden one.
Copy cell, paste there, select all and copy from there. Afterwards, close/discard it.
EDIT: Managed to get some code... but it worked, then stopped, then worked again... no idea why...
Sub TempDoc()
Dim WDApp As Word.Application
Dim WDDoc As Word.Document
Application.ScreenUpdating = False
Set WDObj = Sheets("Text2Form").OLEObjects("WDOC")
WDObj.Activate
WDObj.Object.Application.Visible = False
Set WDApp = GetObject(, "Word.Application")
Set WDDoc = WDApp.ActiveDocument
WDApp.Visible = False
Worksheets("Text2Form").Cells(12, 4).Copy
WDApp.Selection.Goto What:=wdGoToLine, Which:=wdGoToLast
WDApp.Selection.PasteSpecial xlPasteValues
WDApp.ActiveDocument.Content.InsertAfter vbNewLine
Worksheets("Text2Form").Cells(14, 4).Copy
WDApp.Selection.Goto What:=wdGoToLine, Which:=wdGoToLast
WDApp.Selection.PasteSpecial xlPasteValues
WDDoc.Content.Copy
WDDoc.Content.Delete
WDApp.Quit
Application.ScreenUpdating = True
End Sub
您是否尝试过右键单击要粘贴到的单元格,然后单击“选择性粘贴”?
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.