Solved

INSERT PICTURE IN EXCEL USING VB6

Posted on 2009-05-12
5
1,161 Views
Last Modified: 2012-05-06

Dear Experts,

I know it's kind of stupid but i'm really messing up with this problem..
I want to put a picture on specific range on excel. I can put the picture on the
top left of the specific range e.g range("A1")....


But my problem is that i cannot able to set the picture to TOP RIGHT of the specific cell or range...
e.g: i cannot put the picture on the top right of range "E1"...

NOTE: RANGE MAY CHANGE DEPENDING ON USERS...

I really need your help experts...

Thanks in advance...Please put me on the right direction in doing so...


game-master
0
Comment
Question by:game-master
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 10

Accepted Solution

by:
Jon von der Heyden earned 250 total points
ID: 24363430
Could you post what you have.  See my example below:
Sub InsertPic()
 
Dim rngTarget As Range
Set rngTarget = Range("E1")
 
Const strPicPath = "C:\Documents and Settings\jon.vonderheyden\My Documents\My Pictures\Blank Female.JPG"
 
Dim dblLeft As Double
dblLeft = rngTarget.Offset(, 1).Left
 
Dim dblTop As Double
dblTop = rngTarget.Top
 
ActiveSheet.Shapes.AddPicture strPicPath, True, True, dblLeft, dblTop, 100, 100
    
End Sub

Open in new window

0
 
LVL 85

Assisted Solution

by:Rory Archibald
Rory Archibald earned 250 total points
ID: 24363618
You basically need Range F1's Left property and then subtract the width of the picture. That will give you the correct value for the Left property of your picture.
0
 
LVL 13

Author Comment

by:game-master
ID: 24371056


when i run the code more than once...lets say i generate the report twice...
i got an error stating that activesheet it nothing... how do i fixed this...
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 24371686
What code are you running? If you are automating Excel from VB6 you need to fully qualify all Excel objects, so you would need something like objXL.activesheet where objXL is an Excel.Application variable
0
 
LVL 13

Author Comment

by:game-master
ID: 24371909


i've got it!

i find my answer...it's working now!...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question