Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #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!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Argument not optional

What line is highlighted when you hit debug after you get the error message?

--
Regards,
Tom Ogilvy


"Arne Hegefors" wrote:

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!!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Argument not optional

Hi Tom! The problem is that the error message comes directly after I have
pressed the button. I then must press OK on the error message and then
nothing is highlighted in the code. Therefore I cannot really detect where
the problem is. However I changed the code for the button to a direct call
instead of .onaction and then it worked. My code then looked like:

Set stapelDiagramKnapp = .Controls.Add(Type:=msoControlButton)
With stapelDiagramKnapp
.Caption = "Stapeldiagram"
...
end with
call Modul1.arrayLoop

that worked but that means that it runs every time the button is created and
that is not what i want. I just cannot understand what is wrong. As i said it
works fine when I skip the button and just use "F8" starting at the arrayLoop
sub so there must be something strange with the button. but it is the same
code for the two buttons ie I dont really understand where the difference is.
I do not know if this gives you a better understanding of the probelm but if
you have any tips, ideas please help me out! Thanks very much!

"Tom Ogilvy" skrev:

What line is highlighted when you hit debug after you get the error message?

--
Regards,
Tom Ogilvy


"Arne Hegefors" wrote:

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!!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Argument not optional

Hi Tom! I changed the order in the code for the two buttons and then it
worked...Do not ask me why but as long as it works I am happy! Please accept
me thanks for all your help, I know I have been a oain but I just did not get
it! Again tahnk you very much!

"Arne Hegefors" skrev:

Hi Tom! The problem is that the error message comes directly after I have
pressed the button. I then must press OK on the error message and then
nothing is highlighted in the code. Therefore I cannot really detect where
the problem is. However I changed the code for the button to a direct call
instead of .onaction and then it worked. My code then looked like:

Set stapelDiagramKnapp = .Controls.Add(Type:=msoControlButton)
With stapelDiagramKnapp
.Caption = "Stapeldiagram"
..
end with
call Modul1.arrayLoop

that worked but that means that it runs every time the button is created and
that is not what i want. I just cannot understand what is wrong. As i said it
works fine when I skip the button and just use "F8" starting at the arrayLoop
sub so there must be something strange with the button. but it is the same
code for the two buttons ie I dont really understand where the difference is.
I do not know if this gives you a better understanding of the probelm but if
you have any tips, ideas please help me out! Thanks very much!

"Tom Ogilvy" skrev:

What line is highlighted when you hit debug after you get the error message?

--
Regards,
Tom Ogilvy


"Arne Hegefors" wrote:

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!!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Argument not optional

Arne,
You seem to have 2 With blocks active at the same time.
1 - Set stapelDiagramKnapp = .Controls.Add(Type:=msoControlButton)
Which presumably referes to a CommnadBar object.
2 - With stapelDiagramKnapp 'Button
.Caption = "Stapeldiagram"

Whilst the compiler may be able to work this out, it may be erratic.

NickHK

"Arne Hegefors" wrote in message
...
Hi Tom! The problem is that the error message comes directly after I have
pressed the button. I then must press OK on the error message and then
nothing is highlighted in the code. Therefore I cannot really detect where
the problem is. However I changed the code for the button to a direct call
instead of .onaction and then it worked. My code then looked like:

Set stapelDiagramKnapp = .Controls.Add(Type:=msoControlButton)
With stapelDiagramKnapp
.Caption = "Stapeldiagram"
..
end with
call Modul1.arrayLoop

that worked but that means that it runs every time the button is created

and
that is not what i want. I just cannot understand what is wrong. As i said

it
works fine when I skip the button and just use "F8" starting at the

arrayLoop
sub so there must be something strange with the button. but it is the same
code for the two buttons ie I dont really understand where the difference

is.
I do not know if this gives you a better understanding of the probelm but

if
you have any tips, ideas please help me out! Thanks very much!

"Tom Ogilvy" skrev:

What line is highlighted when you hit debug after you get the error

message?

--
Regards,
Tom Ogilvy


"Arne Hegefors" wrote:

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


'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


'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!!



Reply
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 05:50 PM.

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"