Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Resizing of picture different in run time and design time
Very odd. I have a simple macro to resize all the pictures on a page in
order to fit the page breaks. It works perfectly when I step through the code, line by line using "F8" but if I leave it to run from a command button on the sheet, the pictures do resize but to a completely different dimension than instructed. After resetting pagebreaks, the code is simply a for next loop with: AcvtiveSheet.Shapes(i).Select With Selection .ShapeRange.LockAspectRatio = msoTrue .ShapeRange.Height = ht .ShapeRange.Top = yposn .ShapeRange.Left = xposn End With |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Resizing of picture different in run time and design time
the problem probably isn't in the loop you posted. I would need to see the
entire code to spot the problem. You are probably get the the szie from the wrong source location. Probably from a different worksheet. "Broadband-Al" wrote: Very odd. I have a simple macro to resize all the pictures on a page in order to fit the page breaks. It works perfectly when I step through the code, line by line using "F8" but if I leave it to run from a command button on the sheet, the pictures do resize but to a completely different dimension than instructed. After resetting pagebreaks, the code is simply a for next loop with: AcvtiveSheet.Shapes(i).Select With Selection .ShapeRange.LockAspectRatio = msoTrue .ShapeRange.Height = ht .ShapeRange.Top = yposn .ShapeRange.Left = xposn End With |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Resizing of picture different in run time and design time
Thanks - have found that if I change the Screenupdating = true then the
problem goes away. This is good but for the future, I am no wiser as to why the scaling should change just because of the screenupdating property. I've not used the scaleheight property anywhere... Here's the full code: ActiveSheet.PageSetup.Orientation = xlPortrait ActiveSheet.ResetAllPageBreaks 'set options - borders and no. pics on page interval = 6 'gap between images NoOnPage = InputBox("No. pictures per page?", "Picture Lay-Out", 4) 'no of pictures per page 'Find row and column with breaks BreakR = activesheet.HPageBreaks(1).Location.Row BreakC = activesheet.VPageBreaks(1).Location.Column 'Find no. points to breaks pagelength = ActiveSheet.Cells(BreakR, 1).Top pagewidth = ActiveSheet.Cells(1, BreakC).Left 'Set picture height ht = (pagelength - interval * NoOnPage) / NoOnPage 'So lets fit them - first at..... yposn = interval / 2 Application.ScreenUpdating = True For i = 1 To NoPics 'Resize first activesheet.Shapes(PicOrder(i)).Select With Selection .ShapeRange.LockAspectRatio = msoTrue .ShapeRange.Height = ht End With 'now choose x position: odds centred left - evens centred right If i Mod 2 0 Then 'odd number xposn = 7 Else 'even number xposn = pagewidth - Selection.ShapeRange.Width - 7 End If 'now locate pic With Selection .ShapeRange.Top = yposn .ShapeRange.Left = xposn End With yposn = yposn + ht + interval 'set top position ready for next pic Next i "Joel" wrote: the problem probably isn't in the loop you posted. I would need to see the entire code to spot the problem. You are probably get the the szie from the wrong source location. Probably from a different worksheet. "Broadband-Al" wrote: Very odd. I have a simple macro to resize all the pictures on a page in order to fit the page breaks. It works perfectly when I step through the code, line by line using "F8" but if I leave it to run from a command button on the sheet, the pictures do resize but to a completely different dimension than instructed. After resetting pagebreaks, the code is simply a for next loop with: AcvtiveSheet.Shapes(i).Select With Selection .ShapeRange.LockAspectRatio = msoTrue .ShapeRange.Height = ht .ShapeRange.Top = yposn .ShapeRange.Left = xposn End With |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Resizing of picture different in run time and design time
If screen updating is off then this line doesn't get changed
xposn = pagewidth - Selection.ShapeRange.Width - 7 The Width is still the old value since the screen did get updated. "Broadband-Al" wrote: Thanks - have found that if I change the Screenupdating = true then the problem goes away. This is good but for the future, I am no wiser as to why the scaling should change just because of the screenupdating property. I've not used the scaleheight property anywhere... Here's the full code: ActiveSheet.PageSetup.Orientation = xlPortrait ActiveSheet.ResetAllPageBreaks 'set options - borders and no. pics on page interval = 6 'gap between images NoOnPage = InputBox("No. pictures per page?", "Picture Lay-Out", 4) 'no of pictures per page 'Find row and column with breaks BreakR = activesheet.HPageBreaks(1).Location.Row BreakC = activesheet.VPageBreaks(1).Location.Column 'Find no. points to breaks pagelength = ActiveSheet.Cells(BreakR, 1).Top pagewidth = ActiveSheet.Cells(1, BreakC).Left 'Set picture height ht = (pagelength - interval * NoOnPage) / NoOnPage 'So lets fit them - first at..... yposn = interval / 2 Application.ScreenUpdating = True For i = 1 To NoPics 'Resize first activesheet.Shapes(PicOrder(i)).Select With Selection .ShapeRange.LockAspectRatio = msoTrue .ShapeRange.Height = ht End With 'now choose x position: odds centred left - evens centred right If i Mod 2 0 Then 'odd number xposn = 7 Else 'even number xposn = pagewidth - Selection.ShapeRange.Width - 7 End If 'now locate pic With Selection .ShapeRange.Top = yposn .ShapeRange.Left = xposn End With yposn = yposn + ht + interval 'set top position ready for next pic Next i "Joel" wrote: the problem probably isn't in the loop you posted. I would need to see the entire code to spot the problem. You are probably get the the szie from the wrong source location. Probably from a different worksheet. "Broadband-Al" wrote: Very odd. I have a simple macro to resize all the pictures on a page in order to fit the page breaks. It works perfectly when I step through the code, line by line using "F8" but if I leave it to run from a command button on the sheet, the pictures do resize but to a completely different dimension than instructed. After resetting pagebreaks, the code is simply a for next loop with: AcvtiveSheet.Shapes(i).Select With Selection .ShapeRange.LockAspectRatio = msoTrue .ShapeRange.Height = ht .ShapeRange.Top = yposn .ShapeRange.Left = xposn End With |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
I need a basic quick time line design | Excel Discussion (Misc queries) | |||
How to format userform label at design time? | Excel Programming | |||
Date and Time Picker resizing itself | Excel Programming | |||
The design of this website sucks big time | New Users to Excel | |||
Design time events | Excel Programming |