Hi,
I have a chart that I created in excel through VB. I want to try and change the font name from Times New Roman to Symbol. I tried recording the macro in excel but when I use the code in VB it doesn't work. Here is what I got: - Dim xlApp As Excel.Application
-
Set xlApp = New Excel.Application
-
xlApp.DisplayAlerts = False
-
Dim xlWkb As Excel.Workbook
-
Set xlWkb = xlApp.Workbooks.Add
-
Dim xlSht As Excel.Worksheet
-
Set xlSht = xlWkb.Worksheets(1)
-
Dim xlChart As Excel.Chart
-
Dim MyShape As Shape
-
-
Set xlChart = xlWkb.Charts.Add
-
-
xlSht.Cells(8, 2) = 1
-
xlSht.Cells(9, 2) = 2
-
xlSht.Cells(10, 2) = 3
-
xlSht.Cells(11, 2) = 4
-
xlSht.Cells(12, 2) = 5
-
-
-
-
xlSht.Cells(8, 3) = 10
-
xlSht.Cells(9, 3) = 20
-
xlSht.Cells(10, 3) = 30
-
xlSht.Cells(11, 3) = 40
-
xlSht.Cells(12, 3) = 50
-
-
-
xlApp.Visible = True
-
-
xlChart.SetSourceData xlSht.Range("H10"), xlColumns
-
xlChart.SeriesCollection.NewSeries
-
xlChart.SeriesCollection(1).XValues = "=Sheet1!R8C2:R17C2"
-
xlChart.SeriesCollection(1).Values = "=Sheet1!R8C3:R17C3"
- xlChart.Axes(xlValue, xlPrimary).HasTitle = True
-
xlChart.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "p"
-
xlChart.Axes(xlValue, xlPrimary).AxisTitle.AutoScaleFont = True
-
xlChart.Axes(xlValue, xlPrimary).AxisTitle.Font.Name = "Symbol"
-
-
xlChart.ChartArea.Select
-
-
xlChart.ChartArea.Font.Size = 20
-
xlChart.ChartArea.Font.Color = vbRed
-
-
xlChart.ChartArea.Select
-
xlChart.ChartArea.Copy
-
-
Image1.Picture = Clipboard.GetData(vbCFBitmap)
The part in bold is where I try and change the font name.
Can anyone see what I'm doing wrong? This is really important so any help would be greatly appreciated.
Thanks
8 2635
Can you give a more specific description of the problem than "doesn't work"? Do you get an error? If so, what one?
Can you give a more specific description of the problem than "doesn't work"? Do you get an error? If so, what one?
I don't get an error, nothing happens to the axis when I use the commands in bold.
I don't get an error, nothing happens to the axis when I use the commands in bold.
Hm... but the rest of the code works?
Hm... but the rest of the code works?
Yes everything works great. Thats what is really bothering me because all I need to do is change the font of the X and Y axis titles but it just doesn't change.
Yes everything works great. Thats what is really bothering me because all I need to do is change the font of the X and Y axis titles but it just doesn't change.
Very odd.
I don't know what the problem is, but as a workaround, perhaps you could create a Font object, set it the way you want, then assign it to the .Font property of the axis. I've seen this done, but don't have any experience with it.
Very odd.
I don't know what the problem is, but as a workaround, perhaps you could create a Font object, set it the way you want, then assign it to the .Font property of the axis. I've seen this done, but don't have any experience with it.
hmmm, not sure how to do it but I will look into it. Thanks!
hmmm, not sure how to do it but I will look into it. Thanks!
I seemed to have figured it out. Near the bottom of my code I am setting some ChartArea properties and I guess these properties are overriding the AxisTitle properties. If I get rid of that code then the AxisTitle properties work.
I seemed to have figured it out. Near the bottom of my code I am setting some ChartArea properties and I guess these properties are overriding the AxisTitle properties. If I get rid of that code then the AxisTitle properties work.
Cool! If it turns out you still need the ChartArea stuff, perhaps you can just change the order in which you set them or something.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: stainless |
last post by:
I am currently designing a .NET system that takes a piece of text from
a SQL Server database (this is
variable), writes it to an excel spreedsheet in a cell of known length
and height (in...
|
by: Colleyville Alan |
last post by:
I have been working on an application that queries data from Access, loads
it into an array, and then writes it to an Excel spreadsheet. I use the
array approach to have fine control over spacing,...
|
by: Jeff |
last post by:
Hi
I have a report with a graph on it and want to change the minimum and
maximum values for the value axis when it is previewed. This can't be done
by adding code in the Open event as once the...
|
by: Jeff |
last post by:
Hi
I am manipulating MS Graph and can successfully change the minimum and
maximum values for the Y axis, but can't find a way of doing this for the X
axis.
This works for Y axis...
|
by: BerkshireGuy |
last post by:
I have the following Access code that exports to Excel, inserts a
title, changes the color of the title, and then changes the format of
several columns to currency.
The following code sometimes...
|
by: Claus Haslauer |
last post by:
Hi,
I want to create a chart
value (y-axis) vs. time (x-axis). In fact very similar to the
xy(scatter) example in the graph10.chm help-file.
I ran into problems, so I started a very basic *.mdb...
|
by: Marcin Zmyslowski |
last post by:
Hello all!
I have the following problem. I would like to move the x axis values
from my chart. The X Axis Values are very near the x axis, that`s why I
want to put a space between the x axis...
|
by: Sakharam Phapale |
last post by:
Hi All,
How to preserve the old font properties while changing new one?
I posted same question 2 months back, but I had very small time then.
eg. "Shopping for" is a text in RichTextBox and...
|
by: Noel |
last post by:
Hi all,
I'm trying to create a 3D graph, which has 3-axis with different labes.
I need to be able to color each of the bars indervidually.
Something like that in excel, i.e. x- axis (species),...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |