RE: Combined VBA line syntax
- From: Neal Zimm <nealzimm@xxxxxxxxx>
- Date: Wed, 4 May 2005 14:46:01 -0700
Charlie -
Clearer than mud, sure. the 'method' terminology clears it up. I've
just got to learn more about that. I left the blank on purpose trying to
emulate the protection method without realizing the import of what I did.
Live and Learn.
thanks,
Neal
"Charlie" wrote:
> Let me be a little more explicit on the language syntax the compiler is
> expecting. Properties are used to set or get values:
>
> Object.Property = Value
> Value = Object.Property
>
> Methods are functions that are passed values as arguments
>
> Object.Method Arg1, Arg2, Arg3, etc.
> e.g.
> Worksheet.Protect "ABC123", True, True
>
> The arguments must be entered in the order the method is expecting them, and
> missing (optional) arguments must have commas as placeholders (except for
> missing arguments at the end.)
>
> Object.Method Arg1, , Arg3, , Arg5
>
> If you only want to supply specific arguments then you use the argument name
> in the following syntax (and the order is not critical)
>
> Worksheet.Protect Password:=”ABC123”, AllowFormattingCells:=True
>
> In your example you removed the dot between
>
> Cells(x, y).Borders(xlEdgeLeft)
>
> and
>
> LineStyle
>
> Effectively telling the compiler you wanted to call an unnamed method using
> two arguments, LineStyle and Weight
>
> Cells(x, y).Borders(xlEdgeLeft) LineStyle:=xlContinuous, Weight:=xlThick
> (no method name).....................^
>
> Clear as mud?
>
> "Charlie" wrote:
>
> > I think it's because .Linestyle and .Weight are properties that are set to
> > values, while .Protect is a method, which is like a subroutine that accepts
> > arguments. Someone more advanced please correct me if I'm mistaken!
> >
> > "Neal Zimm" wrote:
> >
> > > Being mostly self taught in VBA I tried to combine lines a and b into c,
> > > using line d as an example from recording a macro.
> > >
> > > compiler did not like line c.
> > >
> > > How do you know when "combining" lines will work and when it will not?
> > > thanks.
> > >
> > > Cells(x, y).Borders(xlEdgeLeft).LineStyle = xlContinuous '' a
> > > Cells(x, y).Borders(xlEdgeLeft).Weight = xlThick '' b
> > >
> > > Cells(x, y).Borders(xlEdgeLeft) LineStyle:=xlContinuous, Weight:=xlThick '' c
> > >
> > > ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
> > > '' d
> > >
> > >
> > > --
> > > Neal Z
.
- References:
- Combined VBA line syntax
- From: Neal Zimm
- RE: Combined VBA line syntax
- From: Charlie
- RE: Combined VBA line syntax
- From: Charlie
- Combined VBA line syntax
- Prev by Date: Re: Deleting garbage
- Next by Date: Backup to specific folder if workbook names begins with "NSR" or "MAC"
- Previous by thread: RE: Combined VBA line syntax
- Next by thread: Determine memory usage of objects (like Dictionary)
- Index(es):
Relevant Pages
|