Print Transparent Shapes - excel

I have a map of the warehouse where I work, and I'm trying to make a heatmap of activity that has taken place within a certain aisle.
I have managed to get the VBA working by having permanent red shapes positioned over each aisle, then adjusting the transparency of each box according to the percentage of the aisle.
It looks great on screen, however the multiple methods i have tried for printing does not work;
Expected output (this is what it looks like on screen):
The various methods I have tried all produce the same result, these include :-
Printing directly
SaveAs PDF
Print as PDF (We have PDF virtual printer)
Save Range as a Bitmap
Copy Screen into a Chart, then save export the chart as image
Exported AS PDF :-
Saved as Bitmap :-
When it is printed it has different patterns within the red area, from what i have found, each pattern represents a certain transparency.
Short of using PRTSCN on my keyboard to get it and paste it into paint, i dont know how to move forward with this. This needs to be completely automated (ie, emailable and printable each day), so PRTSCR isnt really an option.
Any ideas would be much appreciated.

For anyone that manages to come across this, what i did in the end, was the get the % of 255 and to set the RGB color value of the shape.
Example psuedo-code below:
for each shp in Activesheet.Shapes
newTrans = 255 * Sheet5.Range("P" & i).Value 'New transparency
Shp.Select
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, newTrans, newTrans)
DoEvents
next shp
This will give a shade of red, based on the percentage on sheet5.

Related

Determine Visible Worksheet Area Size in Points

I am trying to determine the visible worksheet area in points. So far, I have tried the Application.Width, but that gives me the entire area including the scroll bars, and likewise Application.Height includes the ribbon and horizontal scroll bar. What I need specifically is the size of only this viewable worksheet area.
Something I have tried so far is looking at the visible range. For example, if I can see A1 thru AA40, then I can use the code
Debug.Print ws.Range("A1:AA40").Width
Debug.Print ws.Range("A1:AA40").Height
The only problem with this is if I can see half of column AB and half of row 41, then I don't have the full size. Also, it is not adjustable if I decide to change the application window size to half the screen.
I have no need for converting into the number of pixels, I just need the point sizes. Does anyone know a way to get the visible area size, or at the very least how to resize a range to fit only this visible area?
You can access the Windows collection of Application and use the Width and Height properties of items of that collection. E.g.
Debug.Print Application.Windows(1).Width
Debug.Print Application.Windows(1).Height
You can also refer to ActiveWindow and get the properties from that as well.
Example:
Grid's dimensions:
?Activewindow.activepane.VisibleRange.Height, Activewindow.activepane.VisibleRange.Width
The above worked for me, returning the dimensions of only Excel's grid which could be seen on my screen- no scrollbars, no Ribbon, no formula bar - just cells displayed.

Excel Shape Color Not Populating

I have developed a VBA script that (among other things) changes the color of ovals on an Excel sheet based on input data in another sheet. The ovals are part of pre-made groups of shapes that are copied into the workbook with the script. These groups were made a by someone else long before I started working with them.
Most of the time the color population part of the program works perfectly. However, I have found some instances where the color of certain ovals will not populate. Nothing is going wrong in the code. But, if I delete the shape that won't populate color, and copy and paste one that will into its place, it works. The only conclusion that I can come up with is that there is something different about the properties of the ovals. But I'm at a loss for what that might be.
The color is being updated with this statement.
Worksheets(sheetName).Shapes(groupName(i)).GroupItems(shapeName(i)).Fill.ForeColor.RGB = color
But, like I said, the code isn't the issue. That statement works and the color is is not being lost somewhere in the code.
The picture below is the output from a print statement placed right before the part of the code that inserts the color into the oval. If everything is working correctly I would expect to see exactly what I do see.
The next two pictures show a sample of the shapes in question. The top two ovals and textboxes are in a group named CONN 1. The bottom two are in a group named CONN 2. When the program runs it references the shapes within the group based on the individual name of the shape (ie. The line in the immediate window above that says "CONN 1,AE,362,RED" means that the textbox in CONN 1 next to the AE label should show "362" and the oval should turn red).
Here's what they look like before the program runs.
Here's what they look like after the program runs.
The oval on top next to the AF label should have turned red, but it didn't. The difference between CONN 1 and CONN 2 is that in CONN 2 I deleted the oval AF, copied oval AE into the place that oval AF had occupied and renamed it.
Do you have any idea why this might be happening? Thanks.
UPDATE: I just figured out that if I run the macro, select any oval that is not populating with color, manually go to the fill tool and select Automatic, it fills with the proper color.

Excel 2013 ignoring line transparency for shape

I am building an application in Excel 2013 that draws graphs and then fills the area under the graph using AddPolyline to create shapes. I then color these shapes using RGB and Transparency.
Everything is working fine except that Excel completely ignores the Transparency factor for the Line.
myShape.Fill.ForeColor.RGB = RGB(R, G, B)
myShape.Fill.Transparency = T
myShape.Line.ForeColor.RGB = RGB(R, G, B)
myShape.Line.Transparency = T
Currently I am having to reside to a backup solution which is to just make the line invisible using:
myShape.Line.Visible = False
However, this leaves little white markers between my shapes that should otherwise be perfectly aligned.
I have tried things like making the line weight small etc.
Can anyone else confirm this behavior as a bug, or point out what I am doing wrong?
Edit:
Attached a screenshot of the issue.
Make sure what you are dealing is not a border but a true line. Check on LineFormat properties.
For a line, the LineFormat object contains formatting information for the line itself; for a shape with a border, this object contains formatting information for the shape's border.
Try myShape.Line.Visible = msoFalse
Not to forget that Transparency property LineFormat object infact refers to the specified fill of the shape.
You may also record a macro while following this tutorial to check the exact properties of polylines.
On another note, why don't you make the line colour as same as shape colour? In that case, there wouldn't be a different between the line and the shape. However this clearly depends on your usage and intention.
Few references to consider regarding buggy & awakward shape, line properties.

Yellow Text in Solidworks, Can't Change

I'm working on a SolidWorks mechanical drawing generated from a 3-D model I created. I added ordinals to the drawing and text for the sheet title, but all of my text is coming out in yellow:
I've checked that the layer is set to 0, and that the color for layer 0 is set to black. I've also gone through the Options-->System Options-->Colors screen but it did not help me figure out why everything is yellow. It must be a local setting somewhere, because when I try opening the files on another computer it works fine. It's just a pain right now, though, because I need to export to PDF and it shows up as yellow in the PDF instead of black. Is there a setting somewhere that I may have missed?
I would personally go to the settings to determine what type of dimensions SolidWorks assigns the yellow color to.
Tools Options -> Colors -> Color Scheme
By doing that, you will able to figure out what's wrong with the dimension.
Generally speaking, yellow is assigned to dangling dimensions (Dimensions of parts they were modified or deleted).

excel exporting to pdf; graph placement offset

I have some trouble with a document when exporting it to pdf with the builtin pdf export function of excel (2010).
I've generated a graph on my worksheet, with some colored cells arround it. Visually it looks good (even if I zoom on it with the ctrl key + mouse wheel). But when exporting, the graph overlap the surrounding cells.
For example, on the image bellow, I take a screenshot of my graph in excel (at top) and in pdf (at bottom). The red part is my graph (I've colored the background of the graph object). The graph have a black border. And just on the top of the graph, I've colored the background of a cell in blue. Normally, the graph must not overlap the blue cell, because I've manually place it bellow (cut the graph, select the cell bellow the blue one, and past the graph to this emplacement).
But we can see that:
the black border overlap the blue cell (in excel and in pdf version; but it's not really my problem; I've understand that the border in excel object is at outside the object; and then overlapp surround objects/cells).
the graph (in red + the border) has not the same place in excel and in pdf, there is a big offset (it's not a resize problem, this offset is present and the left side too). The place of the graph is more on the left and more on the top in pdf version than it can be!
(I'm using this to automatically generate reports; and the result is not visually good)
Is there any way to overcome this problem?
Hmm, I can't replicate your problem, but I've had similar issues exporting Crystal Reports to PDF. Here's 2 suggestions, neither of which is perfect and I couldn't try them first (again, sorry I couldn't replicate the problem):
Add a white row with a very small height between the graph and the cell. It might even be visually more appealing than the 2 objects one on top of the other.
Make your graph's background transparent and hide the border. Maybe add some extra white space at the top of your graph. That way, they'll still overlap, but it won't be as obvious.

Resources