将RTF(RTF格式)代码转换为Excel中的纯文本 [英] Convert RTF (Rich Text Format) code into plain text in Excel

查看:2289
本文介绍了将RTF(RTF格式)代码转换为Excel中的纯文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我导出数据库查询为Excel,我正在使用RTF格式化的行。





如何转换这些字段变成纯文本?我找到了很老的答案,所以我想知道有没有人知道一个方法。

解决方案

另一个选择可以是使用Microsoft Rich Textbox Control(但不能在x64 Office上测试)

  Sub rtfToText()
使用CreateObject(RICHTEXT.RichtextCtrl)或添加对Microsoft Rich Textbox控件的引用,以便早期绑定和使用新的RichTextLib.RichTextBox
.SelStart = 0'需要被选择
.TextRTF = Join(Application.Transpose(Cells.CurrentRegion.Columns(1)))
[C1] = .Text '设置目标单元格

'或者如果你想要它们在单独的单元格中:
a =拆分(.Text,vbNewLine)
范围(C3)。调整大小(UBound (a)+ 1)= Application.Transpose(a)
End with
End Sub


I exporting a database query as Excel and I am getting rows with RTF formatting.

How can I convert these fields into plain text? I've found answers that are pretty old, so I was wondering if anyone knows a way.

解决方案

Another alternative can be using Microsoft Rich Textbox Control (but can't test it on x64 Office)

Sub rtfToText()
    With CreateObject("RICHTEXT.RichtextCtrl") ' or add reference to Microsoft Rich Textbox Control for early binding and With New RichTextLib.RichTextBox
        .SelStart = 0                          ' needs to be selected
        .TextRTF = Join(Application.Transpose(Cells.CurrentRegion.Columns(1)))
        [C1] = .Text                           ' set the destination cell here

        ' or if you want them in separate cells:
        a = Split(.Text, vbNewLine)
        Range("C3").Resize(UBound(a) + 1) = Application.Transpose(a)
    End With
End Sub

这篇关于将RTF(RTF格式)代码转换为Excel中的纯文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆