Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 28th, 2003, 10:44 AM
malb4uk malb4uk is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 14 malb4uk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hot to adjust the cell to the size of the picture?

Does anyone know the code for macro how to adjust the size of the cell to the size of the inserted picture? Thank you very much for your help. I greatly apreciate it.

Reply With Quote
  #2  
Old August 29th, 2003, 05:37 AM
Silian's Avatar
Silian Silian is offline
Gogga
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 198 Silian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
If you know in which cell the picture is, you can use this code (I hope it works, I had 2 play around it a bit).

Code:
Dim iWidth As Double
Dim iHeight As Double
Dim iDividor As Double
Dim iRest As Double
iDividor = 5.25
iRest = 3.75
'use the index number of the picture in the shapes(index) thingy, e.g. shapes(1) is the first
'picture in that was inserted, shapes(2) the second picture, etc. If all of the pictures are
'the same size, it doesn't matter which one you use.
    iHeight = Worksheets(1).Shapes(1).Height
    iWidth = Worksheets(1).Shapes(1).Width
'use the cells(irow, icolumn) in which the picture sits
    Cells(17, 6).RowHeight = iHeight
    Cells(17, 6).ColumnWidth = (iWidth - iRest) / iDividor


If that doesn't work, you can add this code (instead of idividor = 5.25 and irest = 3.75) to get the values (through code) of the dividor and the rest
Code:
Dim iOldWidth As Double
Dim iNormWidth(2) As Double

For i = 1 To 2
    Columns("D:D").ColumnWidth = i
    iNormWidth(i - 1) = Columns("D:D").Width
Next i
iDividor = iNormWidth(1) - iNormWidth(0)
iRest = iNormWidth(0) - iD

iOldWith = Columns("D:D").ColumnWidth
Columns("D:D").ColumnWidth = iOldWidth

Last edited by Silian : August 29th, 2003 at 05:51 AM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Hot to adjust the cell to the size of the picture?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway