Get color of the task bar in Microsoft Project (VBA) - vba

It's well known in Microsoft Project VBA how to change the color of a task bar using typically:
GanttBarFormatEx TaskID:= CurrentId, GanttStyle:=7, MiddleColor:= myColor
However... i'm looking for a property to get the actual color instead than changing it. I looked into the Microsoft Project VBA reference but failed to found any information.
Thanks for your help

Vincent, Unlike Excel Project doesn't expose the ability to read format colors be they in text or for Gantt Bars. What I normally do is use a indirect method which is to uncover the criteria that set the color and thereby deduce the displayed color. If the color was set by the whim of the user, you're stuck, but normally that user set some criteria (e.g. field value or combination of field values) and you can test for that.

Related

Looking for Word VBA code to highlight text using current default highlight color

I have been searching off and on, high and low, for many months, to no avail, for VBA code that I can include in my macros to highlight text using the current default highlight color. I have looked through my personal resource books and all up and down the land of Google, including here.
I have a bazillion macros created that highlight text every which way to Sunday, in every possible (basic) color, and they all work great. But sometimes I have a scenario where I want to highlight random text in an ongoing manner, multiple times, in a particular color. Then I'll want to switch colors ... for a while. And switch again ... for a while.
I have keyboard shortcuts (many) for a lot of highlighting options, including the built-in command shortcut to highlight text that I have selected manually. So, for example, I can manually select three words to my left, and use Ctrl+Alt+H to invoke the built-in Highlight command, and it will use the current default color.
But I'm unable to automate that further with a macro. For example, I have used numerous different iterations of macros to highlight text as I'm typing it, or to automatically highlight X number of words to my left, or a line or sentence or paragraph. But with each of those macros, I'm forced to declare a specific color. That means that I then have to have voluminous series of macros to be able to do the same thing with each (basic) color variation. That's fine if I just want to infrequently highlight text in a specific color. But when I know I will be using a specific color for the next, say, 20 or 40 highlights, I'd love to set a default color and then just use a generic highlight command rather than a color-centric command (which is more steps).
After much experimentation, I've finally figured out a way to do it. I'm not sure if this is the most efficient way, but it works!
I have many highlight-centric macros that will use this feature, but here is an example of one of them using this feature. I declared the existing color as a string and then used the string rather than a specific color (which I erroneously thought was a requirement). The following macro allows me to highlight while I'm typing:
Sub honHighlightOnTypingSelectWord_DEFAULTCOLOR()
CurColor = Options.DefaultHighlightColorIndex
Application.ActiveDocument.Application.Options.DefaultHighlightColorIndex = CurColor
Selection.Words(1).Select
Selection.Range.HighlightColorIndex = CurColor
End Sub
Problem solved!

How Can I Comprehensively Manage my VBA UserForm's Properties?

I am writing my first VBA Add-In under Microsoft Office Word 2007 with Windows 7 Pro/64. Part of this Add-In is a UserForm. Using the Visual Basic editor that runs from Word, I find there are two ways of viewing, and two ways of modifying a UserForm's properties:
View all properties from Object Browser (F2)
View some properties and edit them from Properties Window (F4)
Manually enter and edit any property from the Code window (F7)
Here is a screenshot of my Properties and Code windows:
A problem I find is that the Properties Window contains only a subset of the UserForm's properties (notice that CanPaste, CanRedo, and CanUndo don't appear in Properties), and changes made in the Properties Window are overridden by changes made in the Code window (e.g., at runtime, Me.Caption from the Code window above overrides the Caption field in Properties).
I suppose I should avoid using Properties at all then, and enter all settings via UserForm_Initialize as shown above. But (a) for some settings, Properties makes several settings at once. For example, selecting Verdana Bold from Properties equals Font = Verdana and Font.Bold = True in Code. And (b) it seems Properties sets the subset of properties it controls to defaults of its choosing, and if I change them I can't see what they started out as.
I therefore desire unified and comprehensive access to all my UserForm's properties at once, including the aforementioned default settings. Does anyone know how to reveal a UserForm's default settings as code, or to automatically open all its current settings in the Code window? Is there an umbrella mechanism I'm not aware of?
I'm not a veteran VBA programmer, but I can't believe my experience is unique. I've searched the 'net in vain for a solution. How do you with more experience manage this dilemma?
You use the Properties window to set appearance-related properties at design time. Those property values will then always apply unless you explicitly change them at run-time with VBA code.
Properties that don't relate to appearance, such as CanPaste and CanRedo relate to the state of the form at run-time, so it doesn't make sense to have them configurable at design-time.
You can change nearly all of the properties at run-time, whether it is in the Initialize event or elsewhere. You can even add controls at run-time, but your changes won't be persisted once the instance of the form terminates.

Resetting a custom made color table

I have made some custom property versions with corresponding custom color tables. Everything seems to work quite well. However, when I select "Reset the color table" in the color tab, Petrel does not set the values to my default values, but to some unknown color sceme.
Does anyone know how it is possible to make Petrel reset to my custom made color table default values? This is on Ocean 2010.
Best regards
Odd Marius Aakervik
Blueback Reservoir AS
The Reset color table button on the Petrel interface will set the color table to the Petrel default for the template associated with your Property. You cannot use this button to reset colors to a custom property version. What you need is a custom template. This is not available in 2010. In the meantime, you can introduce a context menu entry on the Property objects to set the object's color table to your default... or wait for the next version of Petrel.

Setting Lotus Notes section border using VBA

Friends,
I'm using VBA to create Lotus emails populated from an Excel spreadsheet, and I'm stuck on a really silly point.
When I create a new section in the note, business rules require me to give it a border. They've been doing this manually for years and are used to doing this from the Notes UI. They create a new section, then go to its properties and then change it to have a border (please see the border and style part in the properties window in this screenshot).
I can't figure out how to add this border through VBA. Any ideas? I've tried changing the TitleStyle, but that only affects things like fonts and color. I have everything else done, just stuck on the border!
Thanks!
Mike
The NotesRichTextSection class doesn't give you any way to change the border, unfortunately. Rich text items in Lotus Notes aren't supported very well via the API, so often you'll find a mismatch between what you can do on the client vs. what you can do in code.
There might be a workaround if you're up for trying it. First you need to create a simple form in Notes that has a rich text field, let's call it Body, surrounded by a section. Setup the section to appear however you want, with the border set, etc. You'll also need another hidden text field, called Title, and you'll set the section's title to be computed based on that Title field.
Then in your VBA code you're going to create a new NotesDocument based on that form. You'll set the Title field, and you'll add content into the Body rich-text item. Then you'll need to call the ComputeWithForm method followed by the Save method. Finally, you can use the RenderToRTItem method on the document to put the entire document into your original note's rich text field. Make sense?
No guarantees that will work from VBA, but I've done similar things in the past using LotusScript and it did the trick.
You could just set the borders of the cells you are copying using the Borders() property.
Example:
Range("B2:C4").Borders.LineStyle = xlDash
Range("B2:C4").Borders(xlEdgeBottom) = RGB(255,0,0)

SharePoint 2010 - Change table row /cell hover effect

In SharePoint 2010 when you hover over a column heading (i.e. to sort) in a list table, you get a hover effect, how can you supress / change this? I can see it uses OnChildColumn(this), so is there a way to modify this - either preventing the effect (e.g. when sorting can't be done on a column), or using a different background image?
Also want to do the same when you hover over a cell in any of the list table's contents.
I would suggest to use jquery for this.
you can find 's4-ctx' class using selector.
Upload transparent image and on hover you can dynamically change image url. Current it points to "/_layouts/images/ecbarw.png".
Let me know your thoughts on this.
I would create an alternate style sheet that overrides the following from corev4.css:
tr.ms-viewheadertr > th.ms-vh:hover,tr.ms-viewheadertr > th.ms-vh2:hover
anything that uses .s4-ctx-show