VBA代码在不同的Excel 2007版本中不起作用 [英] VBA code does not work in differents Excel 2007 versions

查看:103
本文介绍了VBA代码在不同的Excel 2007版本中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我有 一个问题。我编写了一个代码,用图表自动化一些报告。但它在我的工作站上工作不起作用! [在家里运行得非常好!]

I have  a problem. I wrote a code to automate some reports with charts. But it does not work in my workstation at job! [At home its run very well!]

我在工作中使用:       Win XP SP3,Excel 2007 12.06545.5000。

I use at work:      Win XP SP3, Excel 2007 version 12.06545.5000.

在家:              Win XP SP3,Excel 2007版本12.0.4518.1014。

At home:             Win XP SP3, Excel 2007 version 12.0.4518.1014.

VBE中的引用在两个地方都是相同的。

 

所以,我想格式化图表标题和副标题。

So, I want to format the chart title and subtitle.

例如:

 

字幕

 

后者的格式取代了
首先。

 

标题

字幕

 

如何解决Excel版本的这个问题?

 

代码块:

 

Sub TitleFormat()





ActiveSheet.ChartObjects(1)。激活



$
Title1 = "Titulo"



Title2 = "Subtitulo"



Title = Title1& Chr(10)& Title2



使用 ActiveChart.ChartTitle



。文本=标题



使用 .Characters(开始:= 1,长度:= Len(标题1))。字体



。 Name = " Calibri(Corpo)"



.Bold = True



.Size = 18



结束
$


¥


.Characters(开始:= Len(Title1)+ 2,长度:= Len(Title2))。字体



  .Name = "Calibri(Corpo)"



  .Bold = 错误



  .Size = 10



结束 使用



结束 使用



 

结束 Sub

Sub TitleFormat()


ActiveSheet.ChartObjects(1).Activate


Title1 = "Titulo"

Title2 = "Subtitulo"

Title = Title1 & Chr(10) & Title2

With ActiveChart.ChartTitle

.Text = Title

With .Characters(Start:=1, Length:=Len(Title1)).Font

.Name = "Calibri (Corpo)"

.Bold = True

.Size = 18

End With



With .Characters(Start:=Len(Title1) + 2, Length:=Len(Title2)).Font

  .Name = "Calibri (Corpo)"

  .Bold = False

  .Size = 10

End With

End With

 
End Sub

谢谢!

推荐答案

这些问题与工作站上安装的excel版本无关。 由于每个工作表上安装的字体而产生的差异。 工作站使用安装在
工作站上的字体,如果未安装特定字体,工作站将用另一种类似于指定字体的字体替换指定字体。
The problems has nothing to do with the version of excel installed on the workstations.  the differences that are occuring a due to the Font that are installed on each worksheetation.  The workstations use the Fonts that are installed on the workstations and if a particular font is not installed the workstation will replace the specify font with another font that is similar to the one that was specified.


这篇关于VBA代码在不同的Excel 2007版本中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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