Setting and Retrieving Property Values Without Equal Signs

Asked 2 years ago, Updated 2 years ago, 48 views

Example of Excel bar graph: If you set the bar to a shaded display and record the macro, it appears to be an exceptional description without an equal sign (mixed expression of the .Fill attribute).

With Selection.Format.Fill
    .Visible=msoTrue
    .ForeColor.RGB = RGB (112,48,160)
    .Transparency = 0
    .Patterned msoPattern25 Percent
End With

In order to get and set values in VBA, an equal sign is used in the code, which results in an error.
Could you tell me the solution?

vba

2022-09-29 22:21

1 Answers

Patterned is a method, not a property.
The properties are pattern and two characters shorter.
It seems that the setting is method and retrieval is property.

FillFormat Object (Excel)

method

  • Patterned

properties

  • Pattern

By the way, is the syntax part not only machine translation, but also the original text a little strange?It's about the content.
Did you copy it and mix it?
FillFormat.Patterned method(Excel)

Sets the specified fill pattern.
Syntax
expression.patterning expression Available that presents a FillFormat object.Original Text
Gets the variable that represents the expression FillFormat object. US>Translation
US>Parameters
Name Required/Optional Data Type Description
Specifies the type of MsoPatternType pattern required.

FillFormat.Pattern property(Excel)

Sets or returns a msopatterntype class value that represents a fill pattern.
Syntax
expression.patterns
expression Available that presents a FillFormat object.
Gets the variable that represents the expression FillFormat object.
Notes
Use the patterning method to set the pattern type for fill ****.

The reason why you wrote Strange is that the description of the method's parameters and property values is the same.
I have never compared the exact details, so this may be normal for MS.

Also, if you use = to retrieve and configure the method patterned, both of them will fail.(Maybe it's possible to get it because it says expression?)
You should use the Pattern property to retrieve and configure using =."However, the annotation says ""Use methods for configuration"", so even if you can set it with Pattern=xxxx, I think you should use the method instead."

I've been writing this far, but I've never used either of them, so it's a conceptual explanation based on the specifications of the terms.

The code provided should work.
The questioner misunderstood that Patterned was a property and questioned that = was not used for configuration and retrieval, so he tried to rewrite it to .Patterned=msoPattern25Percent and got an error.


2022-09-29 22:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.