Options

S

SpiroT

Can someone please tell me why I am getting "syntax or object required" error
messages when I try to call the "OptionsCalendar( )"

....

Dim oStartYearIn As Long
Dim oDefaultStartTime As Variant
Dim oDefaultFinishTime As Variant
Dim oHoursPerDay As Double
Dim oHoursPerWeek As Double
Dim oSetDefaults As Boolean
Dim oStartWeekOn As Long
Dim oUseFYStartYear As Boolean
Dim oDaysPerMonth As Double
Dim oBoolean As Boolean

Sub Test1()

oStartYearIn = ThisProject.StartYearIn
oDefaultStartTime = ThisProject.DefaultStartTime
oDefaultFinishTime = ThisProject.DefaultFinishTime
oHoursPerDay = ThisProject.HoursPerDay
oHoursPerWeek = ThisProject.HoursPerWeek
oStartWeekOn = ThisProject.StartWeekOn
oUseFYStartYear = ThisProject.UseFYStartYear
oDaysPerMonth = ThisProject.DaysPerMonth

'This gives me an "object required" message:
Set oBoolean = OptionsCalendar(False, oStartYearIn, oDefaultStartTime,
oDefaultFinishTime, oHoursPerDay, oHoursPerWeek, False, oStartWeekOn,
oUseFYStartYear, oDaysPerMonth)

'This gives me a "sntax error" message:
OptionsCalendar(False, oStartYearIn, oDefaultStartTime, oDefaultFinishTime,
oHoursPerDay, oHoursPerWeek, False, oStartWeekOn, oUseFYStartYear,
oDaysPerMonth)

End Sub
 
S

SpiroT

I've got a little closer, I changed it to:

oBoolean = OptionsCalendar(True, oStartYearIn, oDefaultStartTime,
oDefaultFinishTime, oHoursPerDay, oHoursPerWeek, True, oStartWeekOn,
oUseFYStartYear, oDaysPerMonth)

and now I am getting "run-time error '1101', the argument value is not valid.

Any suggestions are welcomed!!!
 
J

JackD

How about something like this:

sub SpiroT()
OptionsCalendar _
StartYearIn:=3, _
HoursPerDay:=7#, _
HoursPerWeek:=32#, _
StartWeekOn:=3, +
DaysPerMonth:=19
'Etc. Etc.
End sub
 
M

m__murray

SpiroT said:
Can someone please tell me why I am getting "syntax or object required" error
messages when I try to call the "OptionsCalendar( )"

<snip of non working code...>

End Sub

SpiroT,

I don't know if this is much use to you, but... it works if you try
oBoolean = OptionsCalendar(False)
oBoolean = OptionsCalendar(False, oStartYearIn)

and fails on...
oBoolean = OptionsCalendar(False, oStartYearIn, oDefaultStartTime)

this led me to try
oBoolean = OptionsCalendar(False, oStartYearIn, 8, 17)
which worked.

I then tried (all your code, with my lines below replacing their
matching ones in your code)

Dim oDefaultStartTime As integer

oDefaultStartTime = CInt(ThisProject.DefaultStartTime * 24)

oBoolean = OptionsCalendar(False, oStartYearIn, oDefaultStartTime, 17)

(works, but only allows integer hour start times? ie 8:00, but not
8:30)

..
Dim oDefaultStartTime As Double
oDefaultStartTime = CDbl(ThisProject.DefaultStartTime * 24)
oBoolean = OptionsCalendar(False, oStartYearIn, oDefaultStartTime, 17)
(fails - getting stranger?)

I also tried:
oDefaultStartTime = 8.25 '(failed)

but
Dim oDefaultStartTime As String
oDefaultStartTime = "8:25 " (worked)

I think that despite what the documentation says, OptionsCalendar is a
bit fussy about what it will accept, and isn't that tolerant of
variants, in reality.

I hope this helps...
M.
 
M

m__murray

SpiroT,

I've just read your other thread, so looks like you've given up on
this... I hope the simpler option works !

M.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top