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 October 23rd, 2003, 03:56 PM
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
Automatically adjust height of the row

I wqrote this macro, whcih inserts pictures into the excel worksheet and then it adjusts the height of the first row to the height of the picture. But the problem is that this macro only adjust the height of all the rows according to the height of the first inserted picture. What I want is I want each row to automatically adjust to the height if the picture that's placed in this row. Please, let me know what's wrong with my macro and I would also apreciate any suggestions on how to solve this problem. I greately apreciate it. Thank you.
here is the macro:

Sub Macro1()
Dim i As Integer
Dim p As Integer
Dim iHeight As Double
Dim iDividor As Double
Dim Counter As Boolean
Dim sFilename As String
Dim SamePicture As String
Dim SamePicture2 As String
Dim sFilename2 As String
Dim bcontinue As Boolean
Dim spath As String
Dim iRest As Double
iDividor = 5.25
iRest = 3.75
i = 1
SamePicture = njd3
bcontinue = True
spath = "P:\Pictures\JPG\"

Set oFSo = CreateObject("Scripting.FileSystemObject")


While bcontinue
sFilename = Worksheets(1).Cells(i, 3).Value
sFilename2 = Worksheets(1).Cells(i, 2).Value
iPos = InStr(1, sFilename, "-")
If iPos <> 0 Then
SamePicture2 = Mid(sFilename, 1, iPos)
End If
Counter = True
'worksheets is the number of the sheets, e.g. sheet1 = 1 sheet 2 = 2 etc.
'cells is the cell, the first parameter the row, the second the column
If sFilename <> "" And sFilename2 <> "" Then
Range(Cells(i, 1), Cells(i, 7)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
End If
If sFilename = "END" Then
bcontinue = False
Else
Range(Cells(i, 1), Cells(i + 2, 1)).Select 'select the cell where it should be inserted
If sFilename <> "" And sFilename2 <> "" Then
End If
sFilename = spath + sFilename + ".jpg"
If oFSo.fileExists(sFilename) And (SamePicture <> SamePicture2) Then
ActiveSheet.Pictures.Insert(sFilename).Select
'inserts picture and select it
iHeight = Worksheets(1).Shapes(1).Height
Cells(i, 1).RowHeight = iHeight
Counter = False
sFilename = Worksheets(1).Cells(i, 3).Value
iPos = InStr(1, sFilename, "-")
If iPos <> 0 Then
sFilename = Mid(sFilename, 1, iPos)
SamePicture = sFilename
End If
'Selection.ShapeRange.IncrementLeft 5
'Selection.ShapeRange.IncrementTop 12
End If
i = i + 1
End If
p = p + 1
Wend
End Sub
iHeight = Worksheets(1).Shapes(1).Height

Reply With Quote
  #2  
Old October 25th, 2003, 11:04 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
This the property of the rowheight:
RowHeight Property


Returns the height of all the rows in the range specified, measured in points. Returns Null if the rows in the specified range arent all the same height. Read/write Variant.

Remarks

For a single row, the value of the Height property is equal to the value of the RowHeight property. However, you can also use the Height property to return the total height of a range of cells.

Other differences between RowHeight and Height include the following:

Height is read-only.


If you return the RowHeight property of several rows, you will either get the row height of each of the rows (if all the rows are the same height) or Null (if theyre different heights). If you return the Height property of several rows, you will get the total height of all the rows.

i find it in the msdn wen site:http://msdn.microsoft.com/library/d...rorowheight.asp

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Automatically adjust height of the row


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 3 hosted by Hostway