Hi,
I have searched but got stuck on correctly declaring and using the API function getpixel() in vba, hence i making a thread on this subject. I'm aware relevant post exist, but i failed to implement their solution.
What I would like to do: get the color of certain pixel of an image pasted in excel and assign it to a variable.
What I'm asking you:
1. What is the correct way of declaring a function without it giving the error: "comments are only allowed after End Sub, End Function and End Property". I'm using the following line which i found in other threads:
2. Could you comment on why all those parameters are there (why Byval, why do they create an Alias if it's the same name?)
3. hdc is the variable containing the handler for the image object. In the threads i found they use the following code to get the pixel at the pointer along with some other API, but I don't think I would need this one:
What image handler should i use (and why)?
(4. GetPixel returns 3 values as RGB, how would I be able to calculate with this, do i need to make 3 variables?)
It's quite technical, but i hope someone could help me with this. Thank you for your effort!
Dendro
I have searched but got stuck on correctly declaring and using the API function getpixel() in vba, hence i making a thread on this subject. I'm aware relevant post exist, but i failed to implement their solution.
What I would like to do: get the color of certain pixel of an image pasted in excel and assign it to a variable.
What I'm asking you:
1. What is the correct way of declaring a function without it giving the error: "comments are only allowed after End Sub, End Function and End Property". I'm using the following line which i found in other threads:
Code:
Declare Function GetPixel Lib "gdi32" Alias GetPixel(ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
2. Could you comment on why all those parameters are there (why Byval, why do they create an Alias if it's the same name?)
3. hdc is the variable containing the handler for the image object. In the threads i found they use the following code to get the pixel at the pointer along with some other API, but I don't think I would need this one:
Code:
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
What image handler should i use (and why)?
(4. GetPixel returns 3 values as RGB, how would I be able to calculate with this, do i need to make 3 variables?)
It's quite technical, but i hope someone could help me with this. Thank you for your effort!
Dendro