Open shlomizeevy opened 7 months ago
That's an interesting edge case!
It looks like you can take the workbook name you get back from xlSheetNm
as an index into the Application.Workbooks
collection, and then call FullName
to get the real file name.
?Application.Workbooks("Book (3).xlsx").FullName
C:\Temp\Book [3].xlsx
I should say the file name you get back from xlfGetDocument, 88
as an index.
Hi there,
I created an Excel Addin using Excel.Dna.I am using ExcelDna.Integration version 1.6.0. In a custom ExcelFunction function I am trying to get the calling file name using the following code:
` public string TryGetCallingFileName() { var reference = (ExcelReference)XlCall.Excel(XlCall.xlfCaller); var sheetName = (string)XlCall.Excel(XlCall.xlSheetNm, reference);
The issue is that file names that contain box brackets, the brackets are replaced by round brackets. For example, instead of 'book [2]' I'll get 'book (2) The issue relies on
(string)XlCall.Excel(XlCall.xlSheetNm, reference);
which concatenates file name with sheet name. So for sheet name 'Sheet1' I'll get '[book (2)]Sheet1'.What is the best solution to overcome this?
Thanks, Shlomi