|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub 带格式复制单元格内容到WORD文档()
- '
- ' For WORD/WPS:赋值后再修改上标
- '
- Dim myWord, myDoc As Object
- Dim pos%
- Set myWord = CreateObject("Word.Application")
- myWord.Visible = True
- Set myDoc = myWord.Documents.Open(ThisWorkbook.Path & "\1.doc")
- With myDoc.Tables(1)
- For i = 2 To 5
- .Cell(i, 1).Range.Text = Cells(i, 1)
- .Cell(i, 2).Range.Text = Cells(i, 2)
- With .Cell(i, 2).Range
- pos = InStr(.Text, "×10") + 3
- If pos > 3 Then
- While IsNumeric(.Characters(pos))
- .Characters(pos).Font.Superscript = True
- pos = pos + 1
- Wend
- End If
- End With
- Next
- End With
- Set myDoc = Nothing
- Set myWord = Nothing
- End Sub
复制代码 |
|