Working via the Application folder

M

Magnus.Moraberg

Hi,

I have a C# .net application.

In this application, the user clicks on a button to generate an excel
file. I save the macros which compose this generate file within an
excel template file. Therefore when generating the excel file, I need
to read from this template.

As a result, I need the path to this template file from within my
application -

app = new Excel.Application();

workbook = app.Workbooks.Open(@"templateFolder + "\Book1.xlt",
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);

I have added a setup project to my solution, and via this I have added
the template to the Application Folder (under File System). In other
words, this template will be installed into the application folder for
the user in question.

Problem is, how do I handle this when I'm debugging my application and
I don't neccessary have an "Application Folder".

Thanks for your help,

Barry.
 
J

jp2msft

Hi Barry,

C/C++ has preprocessor directives that you could check from within your
code, but I don't know if C# includes these or what they would be called.

In C/C++, you'd write something like:
#ifdef DEBUG
appFolder = m_DebugFolder;
#else
appFolder = m_ApplicationFolder;
#endif

I know this doesn't solve your problem, but maybe this could remind you of
something similar you've seen in C# that you could tell me of, or maybe this
will help someone else see what you are trying to accomplish, and I'm
personally curious to see the answer!

Keep me posted!

Regards,
Joe
 
P

Pavel Minaev

Hi,

I have a C# .net application.

In this application, the user clicks on a button to generate an excel
file. I save the macros which compose this generate file within an
excel template file. Therefore when generating the excel file, I need
to read from this template.

As a result, I need the path to this template file from within my
application -

app = new Excel.Application();

workbook = app.Workbooks.Open(@"templateFolder + "\Book1.xlt",
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);

I have added a setup project to my solution, and via this I have added
the template to the Application Folder (under File System). In other
words, this template will be installed into the application folder for
the user in question.

If your template is part of your VS project, you can change its "Copy
to Output Directory" property so that it is copied to the same folder
as your .exe when the project is built. If your application folder is
defined as the folder in which the .exe file is located, then you can
use this to enable debugging of this feature.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top