Hi
On below line i am getting error
Picture1.FormattedPicture = Nothing
VB.NET
Private Sub Section3_Format(ByVal pFormattingInfo As Object)
Picture1.FormattedPicture = Nothing
Set Picture1.FormattedPicture = LoadPicture(cimage1.Value)
End SubThanks

Sophia CarterRank #4,018 · 371 reputationPosted Apr 16, 2025, 6:49 AM EDT
Hi there! It seems like you're dealing with an Invalid Use of Property issue in your code snippet. The error you're encountering on the line "Picture1.FormattedPicture = Nothing" may be due to the property "FormattedPicture" not supporting the assignment of "Nothing" as a valid value.
In VBA, certain properties do not allow direct assignment of "Nothing" to clear them out. Instead, you can usually set the property to a default or empty value depending on the type of property it is.
If you are trying to clear the "FormattedPicture" property of Picture1, you might need to use a different approach. For instance, if "FormattedPicture" is a picture object, you may set it to a blank image or a default picture instead of directly assigning "Nothing".
Here is an example of how you could modify your code:
Private Sub Section3_Format(ByVal pFormattingInfo As Object) 'Set FormattedPicture to a default or blank picture 'For example: 'Picture1.FormattedPicture = LoadPicture("path_to_default_image.jpg") End SubBy adjusting how you handle the assignment to the "FormattedPicture" property, you can potentially avoid the Invalid Use of Property error. If you are unsure about what values are acceptable for the property or how to clear it properly, it could be beneficial to refer to the documentation specific to the Picture control or seek further assistance.
I hope this sheds some light on your issue. Feel free to let me know if you need more guidance or have any other questions!
Rajeesh MenothRank #118 · 18.4K reputationPosted Apr 17, 2025, 4:36 AM EDT
You should clearly specify the type of error you are encountering, whether it is related to a null object or something else. Otherwise, it is very difficult to suggest an answer.
Muhammad Imran AnsariRank #326 · 7.6K reputationPosted Apr 17, 2025, 2:30 PM EDT
Hello Ramco,
You're getting an error here, probably because:
FormattedPicturemay not support assignment toNothing.Or you're using
= NothingwhereSetshould be used (in older VB versions).If You're Using VB6 / Classic VBA:
// You must use Set when assigning objects: Set Picture1.FormattedPicture = Nothing //Your full code Private Sub Section3_Format(ByVal pFormattingInfo As Object) Set Picture1.FormattedPicture = Nothing Set Picture1.FormattedPicture = LoadPicture(cimage1.Value) End SubIf You're Using VB.NET:
You should not use
Set, and you can't set.FormattedPicturetoNothingif it's not allowed. You may want to skip setting it toNothingentirely if it's causing an error.Good Luck!