首页 > 解决方案 > 是否有 Excel VBA 函数来调整文本大小以适应形状?

问题描述

我在 excel 中画了一个圆圈,里面有一个数字,但是一旦这个数字达到两位数,第二个数字就看不到了。

我希望 textsize 适合形状。

我不能改变圆圈的大小,因为这是基于机会价值的。

我正在做一个业务漏斗,漏斗的相关输入是: - 票号 - 机会价值(潜在收入):用于调整圆圈大小

圆圈在漏斗中绘制,漏斗分为四个阶段,描绘为四种形状。

我努力了:

Public Function DrawCircle(x As Integer, y As Integer, tickets As Collection, ticketIndex As Integer)

    Dim myCircle As Shape

    Dim circleSize As Integer
    circleSize = GetTicketSize(tickets, ticketIndex)

    Dim name As String
    name = "" & tickets.Item(ticketIndex).id

    Set myCircle = ThisWorkbook.Sheets("Graphic funnel").Shapes.AddShape(msoShapeOval, x, y, circleSize, circleSize)
    myCircle.Select
    Selection.ShapeRange.Fill.Visible = msoTrue
    Selection.ShapeRange.TextFrame.Characters.Text = name
    Selection.ShapeRange.Left = Selection.ShapeRange.Left
    Selection.ShapeRange.Top = Selection.ShapeRange.Top - circleSize / 2

    With myCircle
        .DeleteText
        .wrapformat = msoWrapFormat
        .WordWrap = True
        .AutoSize = msoAutoSizeTextToFitShape
    End With

但它返回:“对象不支持此属性或方法”

标签: excelvbaautosizetext-size

解决方案


推荐阅读