Solved

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

Posted on 2012-03-09
2
651 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now