You ever get the feeling Autodesk is just checking off check boxes and not understanding what users actually need? I do. On such example of this is the Slope Stake Report conversion to Excel with images. The images cover the data in the Excel sheet. Not what I would consider a good result. One way to fix this is to either create a VBA code in Excel or in the report. This report will show some code pieces that can be used to fix this catastrophe.
The first thing we would need to do is to get the images. They are called a Shape.
For Each xlsShape As Excel.Shape In sheet.Shapes
' 972 is the approx width of the available space.
If xlsShape.Width > sheetWidth Then
xlsShape.Width = (sheetWidth - 2)
End If
Dim moveDistance As Single = (sheetWidth - xlsShape.Width) / 2
xlsShape.Top = xlsShape.Top + 3
xlsShape.Left = moveDistance - firstColumnWidth
Next
Once we have it we can then move stuff around if we want. In the code above I'm taking the shape and then adjusting the width and centering the image.
We would also want to add rows under the shape. We can get the location of the cell under the image and then insert rows.
xlSheet.Rows(1).Insert()
You’d want to replace the 1 with the current row and add as many rows as you think are needed based on the image height. Once you put it all together now the images will not be over the top of the table.
No comments:
Post a Comment