Solved

INSERT PICTURE IN EXCEL USING VB6

Posted on 2009-05-12
5
1,160 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

732 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