LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Argument not optional

Hello (again)! I am really having big trouble with a seemingly easy
application. I have some buttons that when pressed changes selected charts so
that they look a certain way. I have two buttons and the code for the two
different buttons, one is working fine but the other gives me the error
message "Argument not optional" (as I had not selected any charts but I
have). The strange thing is that the codes for the two buttons are basically
xeroxed from each other ie none or both should give error. I cannot
understand why this is the case. The code for the two buttons is:

Set linjeDiagramKnapp = .Controls.Add(Type:=msoControlButton)
With linjeDiagramKnapp
.Caption = "Linjediagram"
.Style = msoButtonCaption
''' msoButtonAutomatic, msoButtonIcon, msoButtonCaption,
''' or msoButtonIconandCaption
.BeginGroup = True
.OnAction = "ChartModul1.arrayLoop"
End With
'slut linjediagramknapp

'stapeldiagramknapp
Set stapelDiagramKnapp = .Controls.Add(Type:=msoControlButton)
With stapelDiagramKnapp
.Caption = "Stapeldiagram"
.Style = msoButtonCaption
''' msoButtonAutomatic, msoButtonIcon, msoButtonCaption,
''' or msoButtonIconandCaption
.BeginGroup = True
.OnAction = "ChartModul2.arrayLoops"
End With
'slut stapeldiagramknapp

and their respective subs are (first a loop that checks to see if selected
objects truly are charts, thanks very much to NickHK and everybody else who
patiently helped me with this).

Sub arrayLoops()
Dim obj As Object
Dim currentChart As Object

'loopar igenom de selekterade objekten. om ett objekt är en Chart så
'skickas det vidare till Sub stapelDiagramKnapp.
For Each obj In Selection
If TypeName(obj) = "ChartObject" Then
Set currentChart = obj
Call stapelDiagramKnapp(currentChart) 'skickar Chart
End If
Next
'slut på loop
End Sub

Sub stapelDiagramKnapp(argChart As Object)

Dim mySize As Double
With argChart.Chart
'här börjar inställningen för chart
.ApplyCustomType ChartType:=xlUserDefined, TypeName:="Standard"

With argChart
.Height = 150
.Width = 150
.Top = 100
.Left = 100
End With
........
end sub

and the other one:

Sub arrayLoop()
Dim obj As Object
Dim currentChart As Object

'loopar igenom de selekterade objekten. om ett objekt är en Chart så
'skickas det vidare till Sub linjeDiagramKnapp.
For Each obj In Selection
If TypeName(obj) = "ChartObject" Then
Set currentChart = obj
Call linjeDiagramKnapp(currentChart) 'skickar Chart
End If
Next
'slut på loop
End Sub

Sub linjeDiagramKnapp(argChart As Object)

Dim mySize As Double
With argChart.Chart
'här börjar inställningen för chart
.ApplyCustomType ChartType:=xlUserDefined, TypeName:="Standard"

With argChart
.Height = 150
.Width = 150
.Top = 100
.Left = 100
End With
......
end sub.

The one called stapeldiagram gives me the error message "Argument not
optional" but it works if you go into the code and use "F8" to walk through
the lines.... Perhaps it is not possible to see in the code what is wrong but
I have selected the charts and I cannot figure out what is wrong. PLease help
me out! I know I am a pain but I really dont understand why i am having such
trouble with this...(perhaps because I really suck at coding I guess). I
would very much appreciate any help I can get! Thank you all very much for
all your help!!
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile Error Argument Not optional [email protected] Excel Discussion (Misc queries) 1 August 16th 06 04:58 PM
Argument not optional Error 449! Need Help bad_boyu Excel Programming 3 July 26th 06 12:52 PM
Don't understand why I'm getting an argument not optional Brett Smith[_2_] Excel Programming 2 February 8th 06 02:05 PM
optional argument in a function visitor Excel Programming 4 May 13th 05 07:41 PM
Complie Error- Argument not optional Roberta Excel Programming 5 April 4th 05 02:31 PM


All times are GMT +1. The time now is 03:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"