Excel StatusBar字体大小无意中更改 [英] Excel StatusBar Font Size Changing Unintentionally

查看:168
本文介绍了Excel StatusBar字体大小无意中更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在一直在处理一个关于StatusBar的一个非常奇怪的Excel怪癖,并且想知道是否有任何人有洞察力和可能的解决方案。有大约十几个关于如何更新StatusBar的帖子,但没有什么特别的与它的外观相关。我相信一个用户询问更改字体颜色,但解决方案是使用除StatusBar之外的其他东西。

I've been living with a very strange Excel quirk regarding the StatusBar for almost a year now, and was wondering if anyone had any insight, and possible solutions. There were about a dozen or so posts about how to update the StatusBar, but nothing quite related specifically to its appearance. I believe one user asked about changing the font color, but the solution was to use something other than the StatusBar.

无论如何,我使用一个宏来调用单独的建模软件加入。我们有许多案例组织在列,每个案件可能需要运行几次。所以我使用StatusBar让我知道它是哪一列,case#,以及该特定情况的哪一个迭代。看起来像这样...

Anyway, I use a macro to call a separate modeling software add-in. We have numerous cases organized in columns and each case may need to be 'run' several times. So I use the StatusBar to let me know which column it's on, the case #, and which iteration for that specific case. It looks like this...

大StatusBar的字体版本

这是我用来填充StatusBar的单行代码:

This is the single line of code that I use to populate the StatusBar:

Application.StatusBar = "Processing column " & Split(Cells(1, icol).Address(True, False), "$")(0) & ", Case " & iCase & ", Iteration (Loop) " & j & " of " & icoljcount

我的问题是外观在前一个图像(大字体)之间来回跳动,和以下图像(小字体):

The issue I have is that the appearance bounces back and forth between the previous image (Large font) and the following image (Small font):

StatusBar的小字体版本

我在屏幕截图中添加了几个标签,以便您可以看到尺寸更改。我不知道为什么这样做。它不会真正影响功能,除了它让你的眼睛跳跃,如果你正在看它。我看了很多这很讨厌如果我无法解决这个问题,我会犹豫在StatusBar中添加更多有用的信息。

I included a few tabs in the screen shots so you could see the size change. I have no idea why it does this. It doesn't really affect the function, except that it makes your eyes jump if you're watching it. And I watch it a lot. It get's annoying. And I hesitate to add more useful info to the StatusBar if I can't resolve this.

我进入了一个代码,并逐步了解我是否可以确定哪一行当每个字体大小出现时都被执行。当我在我提供的线上击中F8时,出现了BOTH。大版本首先出现,但是在切换到小版本之前,只剩下第二个版本。当我的宏运行大型版本的时候,我会相信这是一个很大的一段时间 - 我相信这是因为下一行代码调用外部程序,这会触发电子表格的重新计算,这是一个非常大的电子表格。

I put in a codebreak and stepped through to see if I could identify which line was being executed when each font size appeared. Turned out BOTH appeared when I hit F8 on the line above I provided. The large version appeared first, but only lasted split second before it switched to the small version. When my macro is running the large version sticks around for a full second - I believe this is because the very next line of code calls the external program, which triggers a recalc of the spreadsheet, and it's a very large spreadsheet.

我可以通过在调用外部程序之前添加100毫秒的睡眠来减轻烦恼。这可能会使Excel分裂第二,它需要翻转到小字体版本,然后被重新计算陷入困境。但是我真的不知道是否会最终会变得恼人。

I may be able to mitigate the annoyance by adding a 100 millisecond 'sleep' before calling the external program. That might give Excel the split second it needs to flip to the small font version before getting bogged down with the recalc. But I honestly don't know if that will end up being more or less annoying.

为了防万一重要,我使用Windows 7,2010 Excel 32- SilverExcel主题,享受高生活,但不在工作,这不会让我几乎一样烦恼。

Just in case it matters, I'm using Windows 7, 2010 Excel 32-bit, "Silver" Excel theme, and enjoy The High Life, but not at work or this wouldn't annoy me nearly as much.

对于冗长的问题,对不起。提前感谢谁打破这个开放。

Sorry for the lengthy question. Thanks in advance to whoever cracks this one open.

推荐答案

我将宏复制在新的子文件中,以将其修剪到人们必须遵循的最低限度循环。要做一个很长的'答案'短(呃),唯一重要的一行是:

I duplicated my macro in a new sub in order to trim it down to the bare minimum that was necessary for people to follow the loop. To make a long 'answer' short(er), the only line that mattered was:

Application.ScreenUpdating = False

当我准备这个答案时,我学到了更多。我的问题可能仍然是ScreenUpdating和调用外部程序的组合。这是一个非常简单的StatusBar与循环的示例代码...

As I was preparing this answer I learned even a bit more. My problem might still be the combination of ScreenUpdating AND calling of the external program. Here's a sample code of a pretty simple StatusBar with loop...

Sub StatusBarTest()

Dim i As Integer

Application.DisplayStatusBar = True
Application.ScreenUpdating = False '<-- toggle on/off to see the effects

For i = 1 To 5

Application.StatusBar = "Loop #" & i & " of 5.  Extremely long StatusBar text so as to amplify a font size change."

'In my full loop this is where my Application.Run statement goes.

Application.Wait (Now + TimeValue("00:00:02")) '2 second delay so user has a chance to witness StatusBar

Next i

Application.StatusBar = False
Application.ScreenUpdating = True

End Sub

当我从Excel运行此子时,我看不到任何字体切换。但是当我从VBA中阅读F8的代码时,每次StatusBar被更新时,我会看到一个更大的字体,这样一来,如果屏幕更新被关闭,如上所述。如果我注释掉屏幕更新行,那么即使在执行代码时也看不到字体切换。

When I run this sub from Excel I do NOT see any font switching. But when I step through the code with F8 from VBA I see the larger font for a split second each time the StatusBar is updated, IF screen updating is turned off as written above. If I comment out the screenupdating line then I don't see the font switch even when stepping through the code.

我真的不明白为什么VBA / Excel的行为就像这个,但我相信我已经确定了原因/效应模式。

I really don't understand why VBA/Excel behaves like this, but I believe I've identified the cause/effect pattern.

这篇关于Excel StatusBar字体大小无意中更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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