Page 1 of 1

Changing the height of a chart by VB-Code

Posted: Fri Mar 16, 2007 10:24 am
by 6919508
Hi,

I have a problem to change (reduce) the height of a chart by Visual Basic Code (VBA, MS Access 2000; ActiveX-Version of Teechart, version 5.0.6; the chart is used in the footer of an Access-Report).

Normally, I have to modify the property height of the chart (in the event OnOpen of the report), for example:

diagram.height = 2500

(assumed: diagram ist the name of the ActiveX-control; The property height has to set in "twips").

This action fails, if the height before was higher than 2500. But this is clear, in the design mode it is also. To reduce the height in the design mode I have to reduce at first the height of the chart (in pixels, the caption "height" is in the language of the Teechart component - English) and then the height of the ActiveX-Control in Access (in cm, the caption "Höhe" is in the language of Access - German). But in VB-Code the property is both called "height". With the above code I modify the property of the ActiveX-Control, but how can I modify the Chart's height? The following I tried:

diagram.Chart.Height = 2500
diagram.TChart.Height = 2500
diagram.ITChart.Height = 2500

But all this fails. How is the correct notification?

Posted: Mon Mar 19, 2007 3:24 pm
by Pep
Hi Thommy,

it works fine here, I've just tried to create a new report with a TChart object into it, adding for example :
Private Sub Report_Open(Cancel As Integer)
TChart2.Height = 2500
End Sub

The Chart height changes and it does not give me any error.
Would you be so kind to tell us the steps we must do in order to reproduce it and send un a simple example ?

reason founded

Posted: Tue Mar 20, 2007 10:33 am
by 6919508
Hi,

thank you for your help, but I think, I have founded the reason: I designed the report with an older version of Teechart (5.0.1). If I insert a new chart in a new report now all works without problems. I noticed earlier that there are problems, if I work with a teechart design with an older version. For example, if I change a property and save the report, the changing is not saved, but have the adjusting before.

Now I have the mission to remove all my charts from my reports, insert new and adjust all properties to convert the older reports to the new version ....

Posted: Tue Mar 20, 2007 12:50 pm
by 6919508
Hi,

now I deleted all my charts and insert they again - now I can change the height of a chart in the designer mode woíthout problems.

But by VB-Code there are still problems. To verify my problem please make the following:

- Create a new Database (in Microsoft Access 2000).
- Create a new report.
- Insert in the detail of the report a Teechart (as ActiveX).
- Input the left (0 cm), top (0 cm), width (10 cm) and height (10 cm). Use the cm-inputs and not the pixel inputs (they will be set automatically to 0 or 378).
- Create an event procedure for the report "On Open", and input the following VB-Code:

Private Sub Report_Open(Cancel As Integer)
MsgBox ActiveXStr0.Height 'Shows "5670" (=10 cm, like input in the design mode)
ActiveXStr0.Height = 1701 '(= 3 cm)
MsgBox ActiveXStr0.Height 'Shows "2880" (=5,079 cm???)
End Sub

Save the code and the report and open it. If you try another value for the height, the same occurs:

Private Sub Report_Open(Cancel As Integer)
MsgBox ActiveXStr0.Height 'Shows "5670" (=10 cm, like input in the design mode)
ActiveXStr0.Height = 4536 '= 8 cm
MsgBox ActiveXStr0.Height 'Shows "2880" (=5,079 cm???)
End Sub

The height is set to 5,079 cm independent on the value I input for the property .height. The bad height displayed by the messagebox is also visible for the chart in the report.

Do you now understand my problem?

Posted: Mon Mar 26, 2007 2:29 pm
by Pep
Hi,

using the latest TeeChart Pro v7.013 (which can be downloaded from the private customers download page) and running the code :
Private Sub Report_Open(Cancel As Integer)
MsgBox ActiveXStr0.Height 'Shows "5670" (=10 cm, like input in the design mode)
ActiveXStr0.Height = 1701 '(= 3 cm)
MsgBox ActiveXStr0.Height 'Shows "2880" (=5,079 cm???)
End Sub

The first msgbox shows "5670" and the second one shows "1695" which I think is correct.
Which TeeChart Pro version are you using ?
Maybe this issue is caused by MS Office temporary files. MS Office creates a temporary type library file for controls used in its documents.

The temporary files are normally housed in:
(for example)
C:\Documents and Settings\yourusername\Local Settings\Temp\Word8.0
or
C:\Documents and Settings\yourusername\Local Settings\Temp\Excel8.0
as TeeChart.exd.

Office is unable to distinguish between versions of TeeChart although the CLSIDs between versions are different. If the temporary file exists for a prior version of TeeChart then Office does not act accordingly by creating a different temporary file, it simply dismisses use of the new version as being incorrect. The solution is to delete the temporary file TeeChart.exd.
The new version of the Control can then be inserted without a problem. Office creates a new temporary file the first time the Control

Posted: Wed Mar 28, 2007 9:09 am
by 6919508
Hi, thank you for your reaction. It must be a very difficult problem, because it isn't solved now.

At first, I can't find the file Teechart.exd in any directory on my hard disk (I have searched it by the standard search tool of Windows XP). Because I use Access 2000, I think it must to find in C:\...\Temp\AccessX.X, but this directory doesn't exist on my hard disk, and the searcher doesn't find this file on another location.

I use the version 5.0.6.0 of Teechart (strangely: on the panel of the info's window this version is displayed, but in the head bar of the window is displayed "Info TeeChart Pro v5.03"), because we have a licence only for this version, and I fear that my boss will not pay an update. In my registry the version 7 is registered also, but it creates by another application on my PC, and I cannot use it, because we have not the licence for this and we want to resell the software containing our TeeChart 5.0.6.0 licence.

In my software I inserted exclusively the version 5.

In the meantime, I deinstalled TeeChart completely and reinstalled it - without solving of the problem.

To verify my problem, could be, that will help you this:

When I insert a Chart to an access report, in the design mode I can change the height of the chart (in cm). But when I copy this chart to the clipboard and it insert to another report from the clipboard, by the copied chart I cannot change the height of the chart in cm: I must change the height in Pixels, then I must input any value into the field for the height in cm, and the correct height is filled automatically!?!