I have faced the following problem: if I write an extension in Visual Studio for Excel file, it saves as the .vsto file in the same location and then uploads in the Excel file on run. But I need .vsto file to be automatically uploaded, when the Excel file starts to execute, and not visible to a person, to whom I will pass the excel file.
Is there any way to do this? I want to place USB-key checking code in the VSTO workbook project (Excel file will be unprotected and opened only if there is a USB-key in the USB-port)
In case you need further clarifications, please do not hesitate to ask in this thread
There is no support in VSTO for embedding your code inside an Excel workbook.
The easiest way of embedding code in a workbook is by using VBA.
Otherwise you would need to find a way of forcing your VSTO code and the workbook to be in the same location.
Related
the question's background is:
I have a solution with excel add-in and excel template projects. the simple function is there is a Ribbon button in add-in that will open the template(.xltx) file in template project to do some business.
I have add the template reference in add-in, so the dependency section existed in the add-in's manifest file.
problem is : I published the add-in project by clickonce and install it. but it always throw exception when open the template.
error message: 'exce..vsto_ae2ff0e19d548faf_0001.0000_bc4bb0e76797a3d0ExcelTemplate1' could not be found. Check the spelling of the file name, and verify that the file location is correct.If you are trying to open the file from your list of most recently used files, make sure that the file has not been renamed, moved, or deleted.'
research: I almost know it's because the .xlsx file didn't be copy to the installed location ( e.g. C:\Users\XXX\AppData\Local\Apps\2.0\XXX), and I also try to modify the manifest file in publish folder, but it's useless, and I also confused with this artile http://blogs.msdn.com/b/vsto/archive/2009/05/20/deploying-multiple-office-solutions-in-a-single-installer.aspx, how to include the vsto and .xltx file to the installed folder?
I guess you will have to build a window installer to do this. if still want to go via click once publish, you need add your windows installer as a prerequisite in VS.
I am trying to open an excel project in my Solution from a Winform Application. Please note:
Winform is my starting Project.
I can add Winform Reference in Excel but I can not add Excel Reference in Winform Project.
As I mentioned I cant find Excel Project in ADD REFERENCE>SOLUTION of Winform project. I also cant add it manually (Invalid dll or COM file Error!).
Any idea?
To open up excel you can use this:
Process.Start("excel.exe"); // or the real path of excel
And to have it open up with a certain worksheet, you could pass as an argument the path of the file:
Process.Start("excel.exe \"c:\My Folder\book1.xlsx\"");
i think iam not really getting what you mean but if you need to open the excel file with one click in the app
and you dont want to write the path of the excel file (may be because you want you app portable)
so the answer is to 1- put the excel file anywhere in the project folder
2- add existing item (. filter) and select the excel file
3-change the properties of the excel file
build action: resource
Copy to output directory:copy always
4-open the properties of the solution and click resources the drag the file and drop it
5-use the (using system.reflection & using system.io & using system.resources)
then write the code like this
string sPath = Path.GetTempFileName();
File.WriteAllBytes(sPath, Properties.Resources.excel File name here);
then take that (spath) and use it as your path so then you can change the project location with the excel file inside it and it will still be working without writing a constant path for it
How to programmatically load an XLL file into Excel when it is linked to other DLLs.
Using c# winforms application + Excel Automation I’m creating Excel Application object. Then I’m using:
bool bXllLoadSuccess = _excelApp.RegisterXLL(_pathXll);
It is OK when XLL is self-contained. The problem occurs when it depends on other DLLs. Even when I put them into the same folder Excel doesn’t want to pick them up.
I tried to do following before loading the XLL but it doesn’t help:
_excelApp.DefaultFilePath = Path.GetDirectoryName(_pathXll);
I have tried this one as well:
Directory.SetCurrentDirectory(Path.GetDirectoryName(_pathXll));
Dependency walker shows no issues – all required files are in the same folder with the XLL.
Any ideas?
Thanks.
UPD: I tried copying all requried dlls into a folder and then added it's path to PATH variable. Didn't help :)
UPD2: I tried to change current directory for both c# app and Excel application object at the same time. Didn't help :(
I want to create a excel 2010 file from C#
so what will be the XlFileFormat Enumeration for it.
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.xlfileformat.aspx
xlOpenXMLWorkbook for a .xlsx macro free workbook.
xlOpenXMLWorkbookMacroEnabled for a .xlsm macro enabled workbook.
The key piece of knowledge is that the new Office 2007 file formats are called Office Open XML.
My task is to extract information from ppt file and compare with another ppt file. I have to use windows platform so i used excel and powerpoint's COM object.
After developing and testing the code in my computer when i exported the file into another computer it just failed. I started to debug in that file, and surprisingly debug was successful from first to last but as soon as click on the executable it fails.
I am totally *ucked up now cause inspite of updating excel dll files into those computers (which will serve the com support) it's not working. In every pc it gives different error message. I don't wanna work COM object anymore. It *ucks.
Can anyone suggest me any open source alternative in which i can read and extract information from Excel and Powerpoint files (both 2003 and 2007 format) ???
My preferred language is c# ........I got an paid solution (aspose) but i don't wanna go for that.
Any help will be appreciated. Just suggest me how can i deal with office files assuming ms office is not installed in my computer.
NPOI works well for Excel; I only know to use the built in, MS object library for PPT files.