Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Opening Excel from VB .NET application


I'm trying to open various Excel files to determine which
ones are not in a valid format. I have the following
snippit of code:

Try
Dim bDisplayAlertsOldValue
Dim workBook As
Excel.Workbook
bDisplayAlertsOldValue =
m_excelApp.DisplayAlerts
m_excelApp.DisplayAlerts =
False
workBook =
m_excelApp.Workbooks.Open(fileName)
workBook.Close(False)
m_excelApp.DisplayAlerts =
bDisplayAlertsOldValue

Catch ex As Exception
MsgBox(ex.ToString())
End Try

The problem I'm encountering is this. If I don't disable
the DisplayAlerts property, then Excel prompts the user
with the standard file is in incorrect format dialog. My
application is going to run without user interaction over
many excel files. If I disable the DisplayAlerts property,
Excel no longer throws the exception that I was catching
after the dialog. Any ideas?

-Dan
  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Opening Excel from VB .NET application


Thanks for the info on how DisplayAlerts property works,
that helps me understand the behavior I'm seeing. Sadly,
it seems the default action for the "This file is not in a
recognizable format" dialog is the OK button opens the
file so you can manually run a text import wizard on the
data Excel does not understand. So the workbook count is
always incremented.

-----Original Message-----
With DisplayAlerts=false, XL assumes the default action

for a given
dialog box. In this case, the only option is to not open

the file.
Just check if the number of open workbooks has changed.

Keep in mind
that XL will attempt to open a wide range of filetypes

including a PDF
file -- don't ask why.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...

I'm trying to open various Excel files to determine

which
ones are not in a valid format. I have the following
snippit of code:

Try
Dim

bDisplayAlertsOldValue
Dim workBook As
Excel.Workbook
bDisplayAlertsOldValue

=
m_excelApp.DisplayAlerts

m_excelApp.DisplayAlerts =
False
workBook =
m_excelApp.Workbooks.Open(fileName)
workBook.Close(False)

m_excelApp.DisplayAlerts =
bDisplayAlertsOldValue

Catch ex As Exception
MsgBox(ex.ToString())
End Try

The problem I'm encountering is this. If I don't

disable
the DisplayAlerts property, then Excel prompts the user
with the standard file is in incorrect format dialog.

My
application is going to run without user interaction

over
many excel files. If I disable the DisplayAlerts

property,
Excel no longer throws the exception that I was

catching
after the dialog. Any ideas?

-Dan

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Opening Excel from VB .NET application


I found a solution, since the file gets opened anyway when
DisplayAlerts is False I can check the FileFormat property
to see if its the correct structured format or if the file
was opened in xlCurrentPlatformText.



-----Original Message-----

Thanks for the info on how DisplayAlerts property works,
that helps me understand the behavior I'm seeing. Sadly,
it seems the default action for the "This file is not in

a
recognizable format" dialog is the OK button opens the
file so you can manually run a text import wizard on the
data Excel does not understand. So the workbook count is
always incremented.

-----Original Message-----
With DisplayAlerts=false, XL assumes the default action

for a given
dialog box. In this case, the only option is to not

open
the file.
Just check if the number of open workbooks has changed.

Keep in mind
that XL will attempt to open a wide range of filetypes

including a PDF
file -- don't ask why.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...

I'm trying to open various Excel files to determine

which
ones are not in a valid format. I have the following
snippit of code:

Try
Dim

bDisplayAlertsOldValue
Dim workBook As
Excel.Workbook
bDisplayAlertsOldValue

=

m_excelApp.DisplayAlerts

m_excelApp.DisplayAlerts =
False
workBook =
m_excelApp.Workbooks.Open(fileName)
workBook.Close(False)

m_excelApp.DisplayAlerts =
bDisplayAlertsOldValue

Catch ex As Exception
MsgBox(ex.ToString())
End Try

The problem I'm encountering is this. If I don't

disable
the DisplayAlerts property, then Excel prompts the

user
with the standard file is in incorrect format dialog.

My
application is going to run without user interaction

over
many excel files. If I disable the DisplayAlerts

property,
Excel no longer throws the exception that I was

catching
after the dialog. Any ideas?

-Dan

.

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Opening Excel from VB .NET application

Neat. Thanks for sharing the solution.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...

I found a solution, since the file gets opened anyway when
DisplayAlerts is False I can check the FileFormat property
to see if its the correct structured format or if the file
was opened in xlCurrentPlatformText.



-----Original Message-----

Thanks for the info on how DisplayAlerts property works,
that helps me understand the behavior I'm seeing. Sadly,
it seems the default action for the "This file is not in

a
recognizable format" dialog is the OK button opens the
file so you can manually run a text import wizard on the
data Excel does not understand. So the workbook count is
always incremented.

-----Original Message-----
With DisplayAlerts=false, XL assumes the default action

for a given
dialog box. In this case, the only option is to not

open
the file.
Just check if the number of open workbooks has changed.

Keep in mind
that XL will attempt to open a wide range of filetypes

including a PDF
file -- don't ask why.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...

I'm trying to open various Excel files to determine

which
ones are not in a valid format. I have the following
snippit of code:

Try
Dim

bDisplayAlertsOldValue
Dim workBook As
Excel.Workbook
bDisplayAlertsOldValue

=

m_excelApp.DisplayAlerts

m_excelApp.DisplayAlerts =
False
workBook =
m_excelApp.Workbooks.Open(fileName)
workBook.Close(False)

m_excelApp.DisplayAlerts =
bDisplayAlertsOldValue

Catch ex As Exception
MsgBox(ex.ToString())
End Try

The problem I'm encountering is this. If I don't

disable
the DisplayAlerts property, then Excel prompts the

user
with the standard file is in incorrect format dialog.

My
application is going to run without user interaction

over
many excel files. If I disable the DisplayAlerts

property,
Excel no longer throws the exception that I was

catching
after the dialog. Any ideas?

-Dan

.

.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel opening from other application bonz Excel Discussion (Misc queries) 1 January 29th 09 05:06 PM
Opening Excel 2007 application Mike Excel Discussion (Misc queries) 2 May 11th 07 02:36 PM
Opening Excel Application difficulty Ariston Excel Discussion (Misc queries) 1 February 20th 05 01:16 AM
Opening a different application from Excel JonR Excel Programming 1 December 31st 04 07:07 PM
Slow-Opening Excel Application Joe Conti Excel Programming 2 October 11th 03 07:30 PM


All times are GMT +1. The time now is 02:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"