I am able to show the range explorer and also the numberformat category of it in my windows app using its default constructor, but really dont know how to retrieve the selected number format and pass it to the form's textbox. I am very new to spreadsheetGear. Can anyone help in using the range explorer. Thanks in Advance
Short answer: After the range explorer is closed, set the the Text property of the text box to the NumberFormat property of one of the cells within the range used in the range used in the RangeExplorer constructor.
textbox1.Text = worksheet.Cells["A1"].NumberFormat;
Longer answer: You can set up the range explorer like the code below.
// Select a range of cells.
workbookView.ActiveWorksheet.Cells["A1:C3"].Select();
// Get the active workbook set.
SpreadsheetGear.IWorkbookSet workbookSet = workbookView.ActiveWorkbookSet;
// Create the Range Explorer which operates on the current range selection.
SpreadsheetGear.Windows.Forms.RangeExplorer explorer
= new SpreadsheetGear.Windows.Forms.RangeExplorer(workbookSet);
// Set up some FormClosed event handler.
explorer.FormClosed
+= new System.Windows.Forms.FormClosedEventHandler(rangeExplorer_FormClosed);
// Display the Range Explorer to the user.
explorer.Show(workbookView);
In the FormClosed event handler, you can get the NumberFormat for anywhere inside the range used in the RangeExplorer constructor. If your text box is called textbox1, it would look like this.
private void rangeExplorer_FormClosed(object sender, System.Windows.Forms.FormClosedEventArgs e)
{
workbookView.GetLock();
try
{
SpreadsheetGear.IWorksheet worksheet = workbookView.ActiveWorksheet;
textbox1.Text = worksheet.Cells["A1"].NumberFormat;
}
finally
{
workbookView.ReleaseLock();
}
}
Related
I want to print Notes-documents directly to an pdf-printer. The documents are selected in a view. I do not want to open the printer dialog form.
Using the "NotesUIView.Print"- method works in principle, however, the generated pdf-documents sometimes look not exactly like the Notes-documents (especially regarding tables).
Therefore I tried to use the "NotesUIDocument.Print" - method:
Option Public
Option Explicit
Const pdfAppName = "PDF-XChange Standard"
Dim dc As NotesDocumentCollection
Dim curDoc As NotesDocument
Dim uidoc As NotesUIDocument
Dim workspace As New NotesUIWorkspace
...
Set dc = curDB.UnprocessedDocuments
...
Set curdoc = dc.GetFirstDocument
Call workspace.EditDocument(False,curDoc)
Set uidoc = workspace.Currentdocument
Call uidoc.Print(1,0,0,False,pdfAppName)
...
Dispite the first parameter in "uidoc.print" is set to "1" the printer dialog form opens. In the printer dialog form the printer "PDF-XChange Standard" is selected correctly. Selecting the "OK"-Button prints the document correctly.
Many thanks in advance for hints.
I'm trying to take a set of names with check boxes next to them and make a system so that you can check some of the names (mark them as "True") and click a button. It would then increment +1 the value next to the names of the people marked true.
Here is a link to a sample sheet:
https://docs.google.com/spreadsheets/d/1gf-BrXXR0cAYCn7bMkvvK65R290NXbP9D6aA68c06C8/edit?usp=sharing
If column A, row 2 (Tim's row) is marked true, I want to increment the value in column C, row 2 by one, so Tim would have a running total of tardies next to his name.
I hope this is do-able. Thanks!
(Now I know what you're trying to get)
In order to increment a value via the press of a button, as far as I know you have to use scripts (Tools -> Script Editor). Here's something I threw together:
// editCell takes the cell to edit and it's new value
function editCell(cellName, value) {
SpreadsheetApp.getActiveSheet().getRange(cellName).setValue(value);
}
// getCell takes the cell's value and returns it
function getCell(cellName) {
return SpreadsheetApp.getActiveSheet().getRange(cellName).getValue();
}
// plusOne adds one to the field supplied. It's linked to the button in the sheet
function plusOne() {
editCell("C2",getCell("C2")+1);
}
In order to make it work, you may need to change the targeted Cell (currently C2). You'll also need to create a drawing (Insert -> Drawing) which will act as the button you'll be able to press. Once inserted, click on the three dots on it and click on Link Script. Type in plusOne. When executing it the first time, it'll ask you to authenticate the use of scripts.
That should do the trick. I hope you have some understanding of Java Script though (to modify the code to your needs optimally).
Edit - Expandable version
So, to make every number behind a ticked field increase by one, you can use this version of the code:
// Adds one to every field within "AddArea" that has a tick in front of it. It's linked to the button in the sheet.
function plusOne() {
var ss = SpreadsheetApp.getActiveSheet();
var range = ss.getRange("AddArea");
var values = range.getValues();
var newValues = [];
for (var i = 0; i < range.getNumRows(); ++i) {
var row = values[i];
if(row[0]) {
newValues.push([true, row[1]+1]);
}
else {
newValues.push([false, row[1]]);
}
}
range.setValues(newValues);
}
You need to define a custom named area, named "AddArea" (Data -> Labeled Areas [or similar]), link the script to a button and allow the script to be run. This was hard but very fun to figure out.
Example Sheet for reference (updated)
Can be achieved with just, for example for C2:
=A2+C2
but you would need to turn on iterative calculation (File > Spreadsheet settings... > Calculation [Max. 1 is adequate]) and I would not really recommend that over a trigger with Google Apps Script.
I have written an Outlook plugin that basically allows emails being received through Outlook to be linked with a website so that the email can also be view in the communications feature of the website. I store additional details within the ItemProperties of a MailItem, these details are basically things like the id of the user the email relates to within a website.
The problem I'm having is any ItemProperties I add to a MailItem are being printed when the email is printed. Does anyone know how to exclude custom ItemProperties when printing an email?
Here is the code that is creating the custom ItemProperty:
// Try and access the required property.
Microsoft.Office.Interop.Outlook.ItemProperty property = mailItem.ItemProperties[name];
// Required property doesnt exist so we'll create it on the fly.
if (property == null) property = mailItem.ItemProperties.Add(name, Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText);
// Set the value.
property.Value = value;
I'm working on Outlook extension and sometimes ago we had the same issue.
One of our team members found a solution. You can create some method which is responsible for disable printing. You can see peace of our code below:
public void DisablePrint()
{
long printablePropertyFlag = 0x4; // PDO_PRINT_SAVEAS
string printablePropertyCode = "[DispID=107]";
Type customPropertyType = _customProperty.GetType();
// Get current flags.
object rawFlags = customPropertyType.InvokeMember(printablePropertyCode , BindingFlags.GetProperty, null, _customProperty, null);
long flags = long.Parse(rawFlags.ToString());
// Remove printable flag.
flags &= ~printablePropertyFlag;
object[] newParameters = new object[] { flags };
// Set current flags.
customPropertyType.InvokeMember(printablePropertyCode, BindingFlags.SetProperty, null, _customProperty, newParameters);
}
Make sure that _customProperty it is your property which you created by the following code: mailItem.ItemProperties.Add(name,Microsoft.Office.Interop.Outlook.OlUserPropertyType.olText);
On the low (Extended MAPI) level, each user property definition has a flag that determines whether it is printable (namely, PDO_PRINT_SAVEAS). That flag however is not exposed through the Outlook Object Model.
You can either parse the user properties blob and manually set that flag (user properties blob format is documented, and you can see it in OutlookSpy (I am its author) if you click the IMessage button) or you can use Redemption (I am also its author) and its RDOUserProperty.Printable property.
The following script (VB) will reset the printable property for all user propeties of the currently selected message:
set Session = CreateObject("Redemption.RDOSession")
Session.MAPIOBJECT = Application.Session.MAPIOBJECT
set Msg = Session.GetMessageFromID(Application.ActiveExplorer.Selection(1).EntryID)
for each prop in Msg.UserProperties
Debug.Print prop.Name
prop.Printable = false
next
Msg.Save
I can not find a way to read the items in a UI ListBox object. I have search and found some methods like getItemCount() and getItemText() in the Google Web Toolkit but they are not available when using the object in a javascript.....
Any ideas?
You will have to pass the list-box widget trough a Server Side call to get the selected data out of it:
function doGet(){
var app = UiApp.createApplication();
var lb = app.createListBox();
lb.setName("calName") //name used to fetch selected result
.addItem("Text Option One", "1")//options for selection
.addItem("Text Option Two","");//first peram display text and second peram value
app.add(lb); // adds listbox to display
app.add(app.createButton("Click Me")//create button
.addClickHandler(app.createServerHandler("showResult") // Create server side execution to handel click
.addCallbackElement(lb))); // add list-boxas element to be passed to server as parameter
return app;
}
function showResult(e){
var app = UiApp.getActiveApplication();
var res = e.parameter.calName;//parameter name same as list-box name given
app.add(app.createLabel("Selected option is " + res));//displays selected option
return app;
}
just create test app and save a version, Use this code for application and view latest code after deploying it.
is there any way to programmaticaly add an hyperlink to the selected text in a MS Word Add-In?
Thanks in advance.
The code below converts selected text into a hyperlink which points to the Microsoft site:
Microsoft.Office.Interop.Word.Range currentRange = Globals.ThisAddIn.Application.Selection.Range;
if (currentRange != null)
{
Microsoft.Office.Interop.Word.Hyperlink hp = (Microsoft.Office.Interop.Word.Hyperlink)
currentRange.Hyperlinks.Add(currentRange, "http://www.microsoft.com");
}
The actual text of the hyperlink,by default, will be your selected text. If you need this text to be of different value, for instance - the actual url address, you can simply change the TextToDisplay property:
hp.TextToDisplay = "http://www.microsoft.com";
I'm not sure exactly how dynamic your logic needs to be but I believe the above example will give you a push in the right direction.
If you are wanting to do this in VBA, it's
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, ...
Sytnax:
expression.Add(Anchor, Address, SubAddress, ScreenTip, TextToDisplay, Target)