Link to a resource excel file from a button

By SG01 ·
Want to use program from CD, so files have to be packaged with the program. Use a form with buttons. Need help with code to open the excel or word files that will be packaged with the program.

At present have got files in solution explorer. Please help with code.

At present use visual Studio 2005 professional and visual basic to code.
Operating System is Window7 and use office 2007 but save files as 2003.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

link is C# but the .net object is the same

by Tony Hopkinson In reply to Link to a resource excel ...

is one way, the other is to use an ole container thingy ActiveDocumentHost, I seem to vaguely remember.

Buy yourself a programming in book, the framework is massive.

Collapse -

linking a file

by SG01 In reply to link is C# but the .net o ...

Tony, The funny thing is that I was using the process.start and it open the file specified but the problem is that if I compile and use on CD it does not pick up the files. I have added windows word comm and added file via resources and you can see it in the solution explorer window but for some reason I'm missing something.

Collapse -

OH !

by Tony Hopkinson In reply to linking a file

If you add the file as a resource, it's compiled into the exe, it get's treated like a string resource or a button image...

Youn need to add your file as a new item to a project, and then set the copy to output directory property to copy allways or copy if newer. (Just like you'd do with a 3rd party dll) Build Action should be Content.

Then when you build it will get pushed into Degbug/bin.

If you compile the file in as a resource. Then to launch excel for it you are looking at loading the resource to a stream, saving it to a temporary file (Sytem.IO.Path.GetTempFileName) and then launching excel for that.


Collapse -

Exec method

by oldbaritone In reply to Link to a resource excel ...

You can call "exec" with the name of the excel or word file, and the shell will use the associated application for that file type to open it.


That's assuming that you require the machine running your software to have Office installed on it already, of course.

Variants are available in several languages, at the bottom of the MSDN page.

Related Discussions

Related Forums