How to open my cheatsheet programmaticlly in eclipse? - eclipse-plugin

I built my own 'cheat sheet'. How to open it programmatically when I open 'Cheat Sheet View' as follows? PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("org.eclipse.ui.cheatsheets.views.CheatSheetView");

You do not open the CheatSheatView like that. Instead use org.eclipse.ui.cheatsheets.OpenCheatSheetAction:
new OpenCheatSheetAction("cheat sheet id").run();
This will open the cheat sheet view except if it is called from a TrayDialog (or derived class) in which case it will add the sheet to the dialog.

Related

Disable File>Share in Excel with VBA

I need a way to disable the ability for a user to go to (or use) the menu File > Share
I have similar for other save commands like below but need something for this feature as well
Application.CommandBars("Worksheet Menu Bar").Controls("File").Controls("Save As...").Enabled = False
Application.CommandBars("Worksheet Menu Bar").Controls("File").Controls("Save").Enabled = False
I have tried:
Application.CommandBars("Worksheet Menu Bar").Controls("File").Controls("Share").Enabled = False
to no avail
My aim is to stop users saving copies of this file (Hosted on a server), I fully understand Excel isn't meant to be secure and there is always a way to do this but want to make it as hard as I can for the average Joe
Regards
You could use a for each loop to extract the available commands:
' Iterate available commands from the file command bar.
Sub PrintAllCommandBarControlNames()
Dim cbControl As CommandBarControl
For Each cbControl In Application.CommandBars("Worksheet Menu Bar").Controls("File").Controls
Debug.Print cbControl.Caption
Next
End Sub
Run on Excel 2010, I couldn't find a share option. Might just be my system. The above returned:
&New...
&Open...
&Close
&Save
Save &As...
Single Web Page (*.mht)
Save &Workspace...
File Searc&h...
Per&mission...
Per&mission
Ch&eck Out
Ch&eck In...
Ve&rsion History...
We&b Page Preview
Page Set&up...
Prin&t Area
Print Pre&view
&Print...
Sen&d To
Propert&ies
&Recent File Name Goes Here
&Recent File Name Goes Here
Sign ou&t
E&xit Excel
The 'backstage' menu (that you get when you click top left File menu) is effectively part of the Ribbon, and not a Command Bar. If you tried disabling Save for instance, using your example, you'll find they don't work on 2010/2013 etc.
There is this answer which tells you how to manipulate those menu items in the ribbon: Remove "Save & Send" from File menu in Excel 2010 using custom XML and one of the items is called TabShare.

How do I set up a dynamic file path in SSIS for an Excel file?

The name of the file changes based on months. Every month you have a new file.
I:\Test\Data_201303.xlsx
How do I set up a connection manager that will work with variable file paths?
Look for the "expression" property on the connection manager. That's where you set it to USER::VariableName.
More detail: if you "edit" the connection manager it will show you the edit window. That's not the one you want. Look at the "properties" window, which is where you will find the "Expressions" entry, in front of an empty box.
Click on the empty box, and it will show you a button with three dots on it. Click on that button. This pulls up the "Property Expression Editor". There is a dropdown with properties like "ConnectionString" on the left. On the right, there is ANOTHER button with three dots. Click on that button to pull up the "Expression Builder". If you have declared any variables, you will find them listed in the upper left hand corner, e.g., as User::VariableName, and you can then drag them into the Expression box, where they will appear as #[User::VariableName].
Not obvious, but doable.
You need to set the expression for the ServerName or ExcelFilePath property to modify ConnectionString of Excel connection manager dynamically using an SSIS package variable.
Here are some SO answers that deal with looping multiple Excel files :
How to loop through Excel files and load them into a database using SSIS package?
How to import Excel files with different names and same schema into database?

stored proc from excel with parameters

If I create a stored proc in sql that has a parameter, can I run that from Excel?
Without using VBA you can use this method. This assumes your stored procedure returns a result set. It also does not make the parameter pulled from a workbook. I think you'd have to use VBA to do that.
Under the 'Connections' section click 'Connections'
Click Add
Click 'Browse for More...'
Click 'New Source...'
Select 'Microsoft SQL Server'
Click Next
Type in the login credentials and click ok.
Select your database
Uncheck 'Connect to a specific table'
Click Finish.
When asked to select a table just click ok.
This should bring you back to the Workbook Connections screen with your new connection added.
Select it and click 'Properties'
Go to the 'Definition' tab.
Set the Command Type to SQL
set the Command text to the SQL you want to run (i.e. "exec spStoredProc 'value'")
Set a new name for your connection
Click ok.
if told that you are severing a connection just agree that, that is okay.
Click 'Close' on your 'Workbook Connections'
Click 'Existing Connections' under the 'Get External Data' section
Select your connection you just made under the 'Connections in this Workbook' section.
Click Open
Set your Import Data options if you want or just click ok
You should now see the result set from the SQL Query in your excel worksheet.
This data can be refreshed from the data that is in the database by going to the data tab and clicking 'Refresh All'
Yes
A standard ADO call from VBA. Or use the Tools..Data thing.
Sure, you can use VBA.
Or you can do it like this: http://blogs.msdn.com/b/excel/archive/2010/06/08/running-a-sql-stored-procedure-from-excel-no-vba.aspx
Here's another nice article on it.
http://www.itjungle.com/mgo/mgo102203-story01.html
I have been working to find a solution to this for a while now and got the best results from following the steps in this article.
http://codebyjoshua.blogspot.com/2012/01/get-data-from-sql-server-stored.html

In Word, Programmatically Open New Document Dialog

I am looking for a way to programatically open the "New Document" dialog in Word 2007. It is the same one you get when you select File->New . You can also open it using the FileNew macro or the "New..." menu command. However, I have been unable to find a way to do this programmatically.
I have tried:
Application.Run MacroName:="FileNew"
and
Dialogs(wdDialogFileNew).Show
and
CommandBars.FindControl(ID:=5746).Execute
but both of these open the old dialog, not the new one that word 2007 uses.
If a 'real' VBA command exists for open that dialog, I can't find it. However, I did find this utterly lame workaround via some quick googling:
SendKeys "%"
SendKeys "F"
SendKeys "N"
It does what you want though! Found it here http://www.eggheadcafe.com/software/aspnet/32228837/new-file-dialog-in-word-2.aspx
You could get the Command ID for the button and execute it?
Dim c As CommandBarControl
Set c = CommandBars.FindControl(ID:=18)
c.Execute
Control ID 18 is the word application ID for the New... button.
I think that you can just use:
Documents.Add
without any parameters.

Unlock/lock form objects with vba

I have an excel worksheet with 2 comboboxes, and 3 scrollbars. I want to protect all the sheet except this form objects (and one cell). When i try to protect the sheet, i can't use the scrollbars and comboboxes. How can i unlock them, keepin the protection for the rest of the sheet with vba ? I tried to unlock the cells linked to the form objects but it still doesn't work.
Thank u
AB
Why not put the cells that need to be modified on a very hidden worksheet.
Create a named range e.g. "InputCell" in a separate worksheet e.g. "SheetWithInputCell". Set the cell link of the combobox to the named range using =InputCell.
Then set the worksheet to VeryHidden. VeryHidden means that users can't right-click on the sheet tabs and unhide it.
To set the sheet to very hidden, go to the VBA IDE (Alt+F11) and look at the Properties window. If you can't see the Properties window, select View > Properties Window.
In the Project Explorer window (View > Project Explorer), select the worksheet to hide and set the Visible property to xlSheetVeryHidden.
Then you can leave the hidden sheet unprotected and lock the sheet with the controls.
What about Menu option Data --> Allow Users to Edit Ranges?