[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Use vb6 program to change size of image in an excel worksheet

Posted on 2012-03-09
2
Medium Priority
?
699 Views
Last Modified: 2012-03-10
I'm using the following code to insert an image into an Excel 2007 Worksheet utilizing VB6 (not a macro).

Const msoFalse = 1
Sub positionpicture()
Dim p As Picture
Dim wkb As Workbook
Dim wks As Worksheet
Dim pBeginX As Single 'relative to upper-left corner of document
Dim pBeginY As Single 'relative to upper-left corner of document
Dim pEndX As Single 'relative to upper-left corner of document
Dim pEndY As Single 'relative to upper-left corner of document
Dim InchToPoint As Single

    Set wkb = ActiveWorkbook
    Set wks = Sheets("Sheet1")
   
    '18 points per .25 inches
    InchToPoint = 18 / 0.25
   
    '2 inches from the left, 6 inches down
    pBeginX = 1 * InchToPoint
    pBeginY = 1 * InchToPoint
    pEndX = 11 * InchToPoint
    pEndY = 11 * InchToPoint
   
    Set p = wks.Pictures.Insert(App.Path & "\" & "tlsig.jpg")

    'keep or lock the aspect ratio
    p.ShapeRange.LockAspectRatio = msoFalse
    'Top left corner
    p.Locked = False
    p.Left = pBeginX
    p.Top = pBeginY
End Sub

How can I resize the image and position it? The image is not responding to the above attempt to position it nor is it responding to the following code:
p.left = wks.range("A39").left
p.top = wks.range("A39").top

Thanks.
0
Comment
Question by:tlengnick
[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 Comments
 

Accepted Solution

by:
tlengnick earned 0 total points
ID: 37705324
I got it:

Sub PositionPicture3()

Dim Excel_App As Excel.Application
Const msoFalse = 1

With Excel_App
  ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Select

    With Selection
        .ShapeRange.LockAspectRatio = msoFalse
        .ShapeRange.Top = 660
        .ShapeRange.Left = 10
        .ShapeRange.Width = 200
        .Placement = xlMoveAndSize
    End With
End With
0
 

Author Closing Comment

by:tlengnick
ID: 37705327
Found the answer online... figured I'd add it to knowledgebase.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

650 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