Excel2007 sheet returns workbook.name as temp file.

S

Sharad Birajdar

I have Office 2003 with compatibility pack installed on my machine and add-in
written for excel in C#.NET. In this add-in, On App_WorkbookOpen event, i
want to get name and fullname of the workbook. For example:

string sFileName = theworkbook.Name;
string sFullFilePath = theworkbook.FullName;

When opening 2007 workbooks, my addin gets the name of the temp
files! So workbook.name, workbook.fullname and workbook.path all
point to the .tmp file. This works correctly for any pre-2007
workbooks.

Is there a way around this?

Thanks and Regards
Sharad
 
C

Charles Williams

I believe this is a function of the file conversion process that is done by
the compatibility pack.
The last time I was working with the compatibility pack I had similar
problems.
I used code like this to test if the workbook was a converted temp file
If LCase(ThisWorkbook.Name) Like "xl???????.xls" Then

You might be able to bypass the problem by saving in 2007 as .xls, or by
trapping the Save event in 2007 and storing the workbook name in a Defined
Name, or by doing a SaveAs in 2003

Charles
__________________________________________________
The Excel Calculation Site
http://www.decisionmodels.com
 
S

Sharad Birajdar

Charles,

Thanks for your reply. My workbook is in *.xlsm format and which can not be
changed. Niether, I can "save" or "saveAs" this sheet as I do in-memory
processing of excel sheets using my C# addin.

Do you have any idea if I can wait till the sheet gets completly converted?
And what shall I do if I didnt get format as "*.xlsm"?

I want a way by which I will surely get fullname/Name of workbook.

Thanks for your help.

Regards
Sharad
 
C

Charles Williams

Hi Sharad,

try the c# equivalent of this code in your Workbook_Open event
Application.OnTime Now + TimeValue("00:00:01"), "GetName"

where GetName gets the workbook.Name etc.

But if you are doing in-memory processing why do you need the workbook name?
Can't you just use an object variable that points to the workbook?

regards
Charles
__________________________________________________
The Excel Calculation Site
http://www.decisionmodels.com
 

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