WorkbookOpen in COMAddin for CSV-files

P

Peter Karlström

Hi

We have an Excel COM-Addin created wich trapps the WorkbookOpen event.
This works fine for all Excel sheets.
But we have problems in our CSV-file import routine, and it seems that the
above event isn't triggered for the CSV-file if Excel is not started
beforehand.
The CSV-file is opened from a web application (IE).
If the file is saved on disk before opened it works, but not if you choose
Open in the browser dialog.

Does anybody have a clue?

Thanks in advance
 
J

Joel

the workbook is being open in a mdoe where macros are not enabled. this is
to prevent viruses from spreading using macros inside of workbooks. I'm not
sure if the webserver is causing the problem or the method you are using to
open the workbook. Can you give details on how the workbook is being opened?
 
P

Peter Karlström

Hi Joel

There are no macros involved. COM Addin is as DLL-addin.
Th COM Addin is activated when the CSV-file opens, but the builtin Excel
WorkbookOpen event is not triggered.
It IS triggered with the exact same file if Excel is already started.

Best Regards
 
J

Joel

The com addin is treated the same way as a macro would be in terms of
security. If the workbook is opened in READ-ONLY mode then neither the addin
or the macros will run. The web server is probably using some firewall
software to disable the addin from running. I'm trying to determine the
methods you are using to open the workbook to see if there is a way to get
the worbook to open in a non READ ONLY MODE.


A CSV file is just a text file and contains no addins. For the Addin to run
automatically it must either be in a personal.xls file on you PC or there is
an On Open event you have created on you PC. the addin is not in the CSV
file itself. I don't know all the details so I can't give a good answer.
 
P

Peter Karlström

Hi Joel

There is a COM Addin DLL loaded together with Excel when Excel starts,
dispite in what way it starts.
And It also loads and runs even if a workbook is ReadOnly. This is not the
issue.

So, the Addin is always loaded and are running throughout the whole process.

When Excel is pre-started, the CSV file is loaded and the COM Addins event
<ExcelObject>.WorkbookOpen is triggered.
This event (<ExcelObject>.WorkbookOpen) is not triggered when the same file
is opened in the exact same way, if Excel is not previously started.

This is the issue.

This COM Addin is developed in VB6, but we have tested a VB.NET version, and
gets the same result. This is more Excel specific then development
environmental.

Hope this straitens the questionmarks...

Regards
 
J

Joel

I 'm starting to think that the CSV path name may be too long. Excel doesn't
like long path names and sometimes doesn't open when the path name exceeds
around 125 characters. Maybe try putting the CSV file on a short path or Map
a Network drive to the folder where the CSV file is located to shorten the
path name.

Another possibility is the command line that opens the CSV file is modified.

See the last option on this webpage for command line options. One
possibility is the command line option is wrong (or gets changed by the
operating system).

http://office.microsoft.com/en-us/excel/HA101580301033.aspx


Because you are dealing with a CSV file something is opening excel using the
wrong command line option to run the addin. If you open a window explorer in
XP (not IE explorer) under

tools - options folder - Options - advance - Open

You can look under CSV file type there is an OPEN option that contains the
command line that is used to open the CSV

Application used to perform action
"C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE" /e

DDE Message
[open("%1")]
 
C

Colbert Zhou [MSFT]

Hello Peter,

I have test with the following steps, but cannot reproduce the issue in my
side.

1.Write an Excel AddIn(I write in managed codes, but I think that should
not be related to the problem)
--------------------Codes--------------------------------
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
this.Application.WorkbookOpen += new
Microsoft.Office.Interop.Excel.AppEvents_WorkbookOpenEventHandler(Applicatio
n_WorkbookOpen);
}

void
Application_WorkbookOpen(Microsoft.Office.Interop.Excel.Workbook Wb)
{
MessageBox.Show(Wb.Name);
}
---------------------------------------------------------------

2.Upload a test.csv file into my sharepoint site.

3.Open an IE to navigate to the test.csv file's url
(http://devforum/Temp/test.csv)

4.I see a messagebox popup before the csv file is opened in a new created
Excel instance.

I think the difference may be from,
1. The Excel version. (The event implementation may have some changes to
cause the issue.) In my side, I use the Office 2007 with SP2 and all
updates.
2. The Internet Explorer version( This process involves some actions with
IE. So how IE to download and start an Excel, open Workbook can be
different ). I am using IE8 at my side.

So could you please clarify your environment for a future investigation on
the issue?



Best regards,
Ji Zhou
Microsoft Managed Newsgroup Support Team
 

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