View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Arne Hegefors Arne Hegefors is offline
external usenet poster
 
Posts: 244
Default Refering to another module

Hello NickHK! Sorry for my late reply, been busy. Thank you very much for
your patient help, you save my life on a daily basis! My problem is that I
get different error messages when trying to run the code. Now I get "Object
does not support that method". I guess I mixed something up in the code but I
really do not know how to write it. The code works like this (it is basically
your code). First I have the loop that checks to see if it is a chart:

Sub arrayLoop()
Dim obj As Object
For Each obj In Selection
If TypeName(obj) = "ChartObject" Then
Call linjeDiagramKnapp(obj.Chart)
End If
Next
End Sub

after that I do the actual configurations of the chart(s).

Sub linjeDiagramKnapp(argChart As Object)
Dim mySize As Double
With argChart.Chart
.ApplyCustomType ChartType:=xlUserDefined, TypeName:="Standard"
With argChart.Chart
.Height = 150
......

I guess it is these last lines that the problem is to be found but I do not
know how to write it. I tried changing it on the basis of your reply but with
limited success. Please help me! Any help is very much appreciated and again
thank you very much for all your assistance!

"Arne Hegefors" skrev:

I have a small problem with a macro. I have two different moduls in my code.
In module1 i have the code for some buttons and so and in module2 i have the
code for what happens if i press the buttons. However my code has trouble
finding the different modules and I need help on how to write this properly.
Code in module1:

Sub Create_Menu()
Dim MyBar As CommandBar
Dim MyPopup As CommandBarPopup
Dim button1 As CommandBarButton
.....
Set button1 = .Controls.Add(Type:=msoControlButton)
With button1
.Caption = "Button!"
.BeginGroup = True
.OnAction = "button1_Click"

and in modul2:

Sub button1_Click()
Dim objChart As ChartObject


Now I need help with how to refer to the sub. My code is quite messy if i
have to have it in the same module so it would be prefect it that was
possible. Thanks very much in advance!