So i have a couple questions here and i will jump right in.
I have an Excel DNA Addin with quit a few things going on.
1. Can I have Multiple Ribbons with Callbacks?
public class USExcelRibbon : ExcelRibbon
{
//Callbacks for USEcelRibbon Here
}
In a completely different class:
public class USExcelRibbonTwo : ExcelRibbon
{
//Callbacks for USEcelRibbon Here
}
My goal is to have a ribbbon for each business unit within our orginization. I have a class that determins who the user is and shows the appropriot ribbon.
I may have up to 6 ribbons in which different bussiness unit may need features and others may not. I determine if the Ribbon group is shown by the follwoing:
*.dna File
<group id="DataGroup" label="Data Files" getVisible="GetVisible">
<splitButton id="splitButton" size="normal" >
<button id="button" imageMso="TableExcelSpreadsheetInsert" label="Replay CSV " />
<menu id="menu">
<!--done-->
<button id="CaliberDataFileReplayBtn"
imageMso="RecurrenceEdit"
onAction="ReplayCaliberAndMeyersDataCsv_Click"
screentip="Replays a Caliber or Meyers files"
supertip="Replays a caliber log (*.csv) Or Meyers Adt (*.adt) File. Caliber files must have the header section at the top of file and must contain the file extention (*.csv). Meyers files must contain the file extention (*.adt)"
label="Caliber/Meyers" />
<button id="DataFileReplaySlidingSleevebtn"
imageMso="RecurrenceEdit"
onAction="ReplayCaliberMeyers_Click"
screentip="Replays Files while being written too"
supertip="Replays a meyers (*.adt) and strips out the zone from the file.
Example is the file has 49 Zones worth of data but you only want to replay Zone 10. Thsi action can be completed while the (*.adt) file is being written to by mview."
label="Sliding Sleeve Replay" />
<!--<button id="DataFileReplayFracProBtn"
imageMso="RecurrenceEdit"
onAction="ReplayCaliberMeyers_Click"
screentip="Fracpro Data File Replay"
supertip="Will replay a Fracpro File"
label="FracPro" />-->
<button id="DataFileReplayIgnitionBtn"
imageMso="RecurrenceEdit"
onAction="ReplayFileIgnition_Click"
screentip="Ignition Data File"
supertip="Will replay an Ignition Data File"
label="Ignition" />
</menu>
</splitButton>
</group>
getVisible Function:
public bool GetAccess(IRibbonControl control)
{
if (control.Id == "AccountsRecievableId")
{
return UserExistsFracFocus();
}
if (control.Id == "AdminGroupId")
{
return UserExistsAdmin();
}
if (control.Id == "ForecastingGroupID")
{
return UserExistsForecast();
}
if (control.Id == "AzureGroupId")
{
return true;
}
//Return True for Groupd not Above
return true;
}
Trying this i get two seperate ribbons showing up based on users seems to be a challenge.
Additionally,
When a user clicks a button on the ribbon i Get the Open Excel Docuemnt and Determine if that Document is the correct one based on the Keyword of the Document added:
public Workbook GetOpenWorkbook(string KeyWord)
{
List<OpenWorkBookModel> Books = new List<OpenWorkBookModel>();
foreach (Workbook Book in ExcelApplicationBooks)
{
OpenWorkBookModel view = new OpenWorkBookModel
{
ExcelBook = Book,
Filename = Book.FullName,
KeyWord = Book.Keywords
};
view.Version = view.GetVersion();
Books.Add(view);
}
var BookByKeyWord = Books.Where(o => o.KeyWord == KeyWord).Select(o => o.ExcelBook).ToList();
if (BookByKeyWord.Count > 1)
{
return ExcelApplication.ActiveWorkbook;
}
else if (BookByKeyWord.Count == 1)
{
return BookByKeyWord.First();
}
return null;
}
My problem is that when i get the OPEN workbooks when a user clicks a Button the Application Object may not contain the open Workbooks within the Application Object. I get the Application Object using the Follwing:
(Microsoft.Office.Interop.Excel.Application)ExcelDnaUtil.Application;
however it seems when a user Select File >> Open and Opens a Naother document the Appliction Object Only Contains a Single workbook and Not TWO as i expect.
I have looked at Windows API and getting the EXCEL.ExE Process but i feel that's complicated. Any thoughts on dealing the the SDI and Excel 2013 64 bit?
FYI: our company is moving to Office 365 soon.
thanks for any information you can provide,
lastly,
thanks for the work on excel-dna. I love it.