繁体   English   中英

Excel UserForm多行文本框会截断文本

[英]Excel UserForm Multiline Textbox truncates text

我在Excel VBA项目的UserForm上的框架中放置了多行启用文本框。

MaxLength设置为0。IntegralHeight = True。 换行=正确。 允许使用垂直滚动条。

在运行时,当我展示表单时,文本框的内容在440个字符后被截断。 我仍然可以输入更多文本,并且垂直滚动条也可以正常显示,即使将文本框内容保存到工作表中的单元格中,也可以很好地保存所有文本。

在设计时,我可以将Text属性(默认控制值)设置为所需的任意多个字符,并且它们在设计时可以正确显示,但是在运行时-在演示文稿中会被截断(在设计时仍然完整) 。

尝试将MaxLength设置为10,000-没有帮助。

在那个项目中,我还有其他形式的带有多行文本框的表单,在这种表单中没有这种行为-一切正常。

知道为什么会这样吗?

Windows 10上具有最新更新的Excel 2016。

我在Excel 2016上尝试了Windows 10上的最新更新,并且运行正常。

您可以做的是删除用户表单,然后创建一个新的新用户表单,然后尝试在其中进行操作。 该用户表单中可能存在某种编码问题,因此建议创建一个新的编码问题。

如果还有疑问,可以问我:)

希望这可以帮助 !

谢谢大家提供的建议。

我发现了问题。

我有一个通用函数,用于根据包含格式化字符串的表对表单进行格式化。 将“常规”格式应用于此多行文本框(作为表中缺少格式输入项的默认设置)以某种方式导致了这种截断。

如果现在在表中找不到任何条目,我现在将跳过格式化控件。

复制:

在干净的工作簿上,创建一个UserForm1,添加一个带有垂直滚动条的多行文本框,将其命名为“ txtTest”。

将其复制为表单的Init事件:

Private Sub UserForm_Initialize()
    Me.txtTest.Value = "Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book. It usually begins with: " & Chr(10) & _
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." & Chr(10) & Chr(10) & _
        "The purpose of lorem ipsum is to create a natural looking block of text (sentence, paragraph, page, etc.) that doesn't distract from the layout. A practice not without controversy, laying out pages with meaningless filler text can be very useful when the focus is meant to be on design, not content. " & Chr(10) & Chr(10) & _
        "The passage experienced a surge in popularity during the 1960s when Letraset used it on their dry-transfer sheets, and again during the 90s as desktop publishers bundled the text with their software. Today it's seen all around the web; on templates, websites, and stock designs. Use our generator to get your own, or read on for the authoritative history of lorem ipsum."

    Me.txtTest.Value = Format(Me.txtTest.Value, "General")
End Sub

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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