Excel VBA: Fill.UserPicture
At cell.Comment.ShapeRange... I get an error: "Run-Time error '1004': Application-defined or object-defined error". What is wrong with it?
Cells(cell.Row, 6) is the reference column that contains the urls for the images. E.g. http://somelink.com/img.jpg
Sub test()
Dim rng As Range
Set rng = Range("B2:B2331")
For Each cell In rng.Cells
cell.AddComment
cell.Comment.Text Text:="Owner:" & Chr(10) & ""
cell.Comment.ShapeRange.Fill.UserPicture Cells(cell.Row, 6).Value
Next
End Sub
microsoft-excel vba
add a comment |
At cell.Comment.ShapeRange... I get an error: "Run-Time error '1004': Application-defined or object-defined error". What is wrong with it?
Cells(cell.Row, 6) is the reference column that contains the urls for the images. E.g. http://somelink.com/img.jpg
Sub test()
Dim rng As Range
Set rng = Range("B2:B2331")
For Each cell In rng.Cells
cell.AddComment
cell.Comment.Text Text:="Owner:" & Chr(10) & ""
cell.Comment.ShapeRange.Fill.UserPicture Cells(cell.Row, 6).Value
Next
End Sub
microsoft-excel vba
Shouldn't you have a shape somewhere?
– Raystafarian
Dec 9 '15 at 18:58
@Raystafarian the comment is the shape.. or no?
– NuWin
Dec 9 '15 at 18:59
I don't think.shaperangeis a property or method ofcomment
– Raystafarian
Dec 9 '15 at 19:06
Well, I've tried just "Shape" which is a property and still get an error.
– NuWin
Dec 9 '15 at 19:10
add a comment |
At cell.Comment.ShapeRange... I get an error: "Run-Time error '1004': Application-defined or object-defined error". What is wrong with it?
Cells(cell.Row, 6) is the reference column that contains the urls for the images. E.g. http://somelink.com/img.jpg
Sub test()
Dim rng As Range
Set rng = Range("B2:B2331")
For Each cell In rng.Cells
cell.AddComment
cell.Comment.Text Text:="Owner:" & Chr(10) & ""
cell.Comment.ShapeRange.Fill.UserPicture Cells(cell.Row, 6).Value
Next
End Sub
microsoft-excel vba
At cell.Comment.ShapeRange... I get an error: "Run-Time error '1004': Application-defined or object-defined error". What is wrong with it?
Cells(cell.Row, 6) is the reference column that contains the urls for the images. E.g. http://somelink.com/img.jpg
Sub test()
Dim rng As Range
Set rng = Range("B2:B2331")
For Each cell In rng.Cells
cell.AddComment
cell.Comment.Text Text:="Owner:" & Chr(10) & ""
cell.Comment.ShapeRange.Fill.UserPicture Cells(cell.Row, 6).Value
Next
End Sub
microsoft-excel vba
microsoft-excel vba
edited Dec 9 '15 at 19:32
Raystafarian
19.5k105089
19.5k105089
asked Dec 9 '15 at 18:55
NuWinNuWin
10628
10628
Shouldn't you have a shape somewhere?
– Raystafarian
Dec 9 '15 at 18:58
@Raystafarian the comment is the shape.. or no?
– NuWin
Dec 9 '15 at 18:59
I don't think.shaperangeis a property or method ofcomment
– Raystafarian
Dec 9 '15 at 19:06
Well, I've tried just "Shape" which is a property and still get an error.
– NuWin
Dec 9 '15 at 19:10
add a comment |
Shouldn't you have a shape somewhere?
– Raystafarian
Dec 9 '15 at 18:58
@Raystafarian the comment is the shape.. or no?
– NuWin
Dec 9 '15 at 18:59
I don't think.shaperangeis a property or method ofcomment
– Raystafarian
Dec 9 '15 at 19:06
Well, I've tried just "Shape" which is a property and still get an error.
– NuWin
Dec 9 '15 at 19:10
Shouldn't you have a shape somewhere?
– Raystafarian
Dec 9 '15 at 18:58
Shouldn't you have a shape somewhere?
– Raystafarian
Dec 9 '15 at 18:58
@Raystafarian the comment is the shape.. or no?
– NuWin
Dec 9 '15 at 18:59
@Raystafarian the comment is the shape.. or no?
– NuWin
Dec 9 '15 at 18:59
I don't think
.shaperange is a property or method of comment– Raystafarian
Dec 9 '15 at 19:06
I don't think
.shaperange is a property or method of comment– Raystafarian
Dec 9 '15 at 19:06
Well, I've tried just "Shape" which is a property and still get an error.
– NuWin
Dec 9 '15 at 19:10
Well, I've tried just "Shape" which is a property and still get an error.
– NuWin
Dec 9 '15 at 19:10
add a comment |
1 Answer
1
active
oldest
votes
First, .shaperange isn't a property or method of comment so you can't use that.
Here's an example that would work -
Sub tete()
Dim rng As Range
Set rng = ActiveSheet.Cells(5, 6)
rng.AddComment
rng.Comment.Text Text:="hi"
rng.Comment.Shape.Fill.UserPicture ("C:Userspathtopic.jpg")
End Sub
Which brings us to the usage of .UserPicture() that requires a path as string. So if your path is in that cell, make sure you're taking the value of it.
So if cell G1 = C:Userspathtopic.jpg
rng.Comment.Shape.Fill.UserPicture (Range("G1"))
would work.
Well with my example, I've used the Shape property and I still get the same error.
– NuWin
Dec 9 '15 at 19:12
You need to surround your string with()for it to be an argument ofuserpicture
– Raystafarian
Dec 9 '15 at 19:15
yes I have () around Cells(cell.Row, 6).Value and still get the error.
– NuWin
Dec 9 '15 at 19:17
So what's in that cell?
– Raystafarian
Dec 9 '15 at 19:18
I have a url.com/image.jpg link. I believe I fixed it. I had the range filtered. Unfiltering it made it work. Thanks for your help.
– NuWin
Dec 9 '15 at 19:21
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1011249%2fexcel-vba-fill-userpicture%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
First, .shaperange isn't a property or method of comment so you can't use that.
Here's an example that would work -
Sub tete()
Dim rng As Range
Set rng = ActiveSheet.Cells(5, 6)
rng.AddComment
rng.Comment.Text Text:="hi"
rng.Comment.Shape.Fill.UserPicture ("C:Userspathtopic.jpg")
End Sub
Which brings us to the usage of .UserPicture() that requires a path as string. So if your path is in that cell, make sure you're taking the value of it.
So if cell G1 = C:Userspathtopic.jpg
rng.Comment.Shape.Fill.UserPicture (Range("G1"))
would work.
Well with my example, I've used the Shape property and I still get the same error.
– NuWin
Dec 9 '15 at 19:12
You need to surround your string with()for it to be an argument ofuserpicture
– Raystafarian
Dec 9 '15 at 19:15
yes I have () around Cells(cell.Row, 6).Value and still get the error.
– NuWin
Dec 9 '15 at 19:17
So what's in that cell?
– Raystafarian
Dec 9 '15 at 19:18
I have a url.com/image.jpg link. I believe I fixed it. I had the range filtered. Unfiltering it made it work. Thanks for your help.
– NuWin
Dec 9 '15 at 19:21
add a comment |
First, .shaperange isn't a property or method of comment so you can't use that.
Here's an example that would work -
Sub tete()
Dim rng As Range
Set rng = ActiveSheet.Cells(5, 6)
rng.AddComment
rng.Comment.Text Text:="hi"
rng.Comment.Shape.Fill.UserPicture ("C:Userspathtopic.jpg")
End Sub
Which brings us to the usage of .UserPicture() that requires a path as string. So if your path is in that cell, make sure you're taking the value of it.
So if cell G1 = C:Userspathtopic.jpg
rng.Comment.Shape.Fill.UserPicture (Range("G1"))
would work.
Well with my example, I've used the Shape property and I still get the same error.
– NuWin
Dec 9 '15 at 19:12
You need to surround your string with()for it to be an argument ofuserpicture
– Raystafarian
Dec 9 '15 at 19:15
yes I have () around Cells(cell.Row, 6).Value and still get the error.
– NuWin
Dec 9 '15 at 19:17
So what's in that cell?
– Raystafarian
Dec 9 '15 at 19:18
I have a url.com/image.jpg link. I believe I fixed it. I had the range filtered. Unfiltering it made it work. Thanks for your help.
– NuWin
Dec 9 '15 at 19:21
add a comment |
First, .shaperange isn't a property or method of comment so you can't use that.
Here's an example that would work -
Sub tete()
Dim rng As Range
Set rng = ActiveSheet.Cells(5, 6)
rng.AddComment
rng.Comment.Text Text:="hi"
rng.Comment.Shape.Fill.UserPicture ("C:Userspathtopic.jpg")
End Sub
Which brings us to the usage of .UserPicture() that requires a path as string. So if your path is in that cell, make sure you're taking the value of it.
So if cell G1 = C:Userspathtopic.jpg
rng.Comment.Shape.Fill.UserPicture (Range("G1"))
would work.
First, .shaperange isn't a property or method of comment so you can't use that.
Here's an example that would work -
Sub tete()
Dim rng As Range
Set rng = ActiveSheet.Cells(5, 6)
rng.AddComment
rng.Comment.Text Text:="hi"
rng.Comment.Shape.Fill.UserPicture ("C:Userspathtopic.jpg")
End Sub
Which brings us to the usage of .UserPicture() that requires a path as string. So if your path is in that cell, make sure you're taking the value of it.
So if cell G1 = C:Userspathtopic.jpg
rng.Comment.Shape.Fill.UserPicture (Range("G1"))
would work.
answered Dec 9 '15 at 19:10
RaystafarianRaystafarian
19.5k105089
19.5k105089
Well with my example, I've used the Shape property and I still get the same error.
– NuWin
Dec 9 '15 at 19:12
You need to surround your string with()for it to be an argument ofuserpicture
– Raystafarian
Dec 9 '15 at 19:15
yes I have () around Cells(cell.Row, 6).Value and still get the error.
– NuWin
Dec 9 '15 at 19:17
So what's in that cell?
– Raystafarian
Dec 9 '15 at 19:18
I have a url.com/image.jpg link. I believe I fixed it. I had the range filtered. Unfiltering it made it work. Thanks for your help.
– NuWin
Dec 9 '15 at 19:21
add a comment |
Well with my example, I've used the Shape property and I still get the same error.
– NuWin
Dec 9 '15 at 19:12
You need to surround your string with()for it to be an argument ofuserpicture
– Raystafarian
Dec 9 '15 at 19:15
yes I have () around Cells(cell.Row, 6).Value and still get the error.
– NuWin
Dec 9 '15 at 19:17
So what's in that cell?
– Raystafarian
Dec 9 '15 at 19:18
I have a url.com/image.jpg link. I believe I fixed it. I had the range filtered. Unfiltering it made it work. Thanks for your help.
– NuWin
Dec 9 '15 at 19:21
Well with my example, I've used the Shape property and I still get the same error.
– NuWin
Dec 9 '15 at 19:12
Well with my example, I've used the Shape property and I still get the same error.
– NuWin
Dec 9 '15 at 19:12
You need to surround your string with
() for it to be an argument of userpicture– Raystafarian
Dec 9 '15 at 19:15
You need to surround your string with
() for it to be an argument of userpicture– Raystafarian
Dec 9 '15 at 19:15
yes I have () around Cells(cell.Row, 6).Value and still get the error.
– NuWin
Dec 9 '15 at 19:17
yes I have () around Cells(cell.Row, 6).Value and still get the error.
– NuWin
Dec 9 '15 at 19:17
So what's in that cell?
– Raystafarian
Dec 9 '15 at 19:18
So what's in that cell?
– Raystafarian
Dec 9 '15 at 19:18
I have a url.com/image.jpg link. I believe I fixed it. I had the range filtered. Unfiltering it made it work. Thanks for your help.
– NuWin
Dec 9 '15 at 19:21
I have a url.com/image.jpg link. I believe I fixed it. I had the range filtered. Unfiltering it made it work. Thanks for your help.
– NuWin
Dec 9 '15 at 19:21
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1011249%2fexcel-vba-fill-userpicture%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Shouldn't you have a shape somewhere?
– Raystafarian
Dec 9 '15 at 18:58
@Raystafarian the comment is the shape.. or no?
– NuWin
Dec 9 '15 at 18:59
I don't think
.shaperangeis a property or method ofcomment– Raystafarian
Dec 9 '15 at 19:06
Well, I've tried just "Shape" which is a property and still get an error.
– NuWin
Dec 9 '15 at 19:10