Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Owerwrite an Excel
Topic Summary: Owerwrite an Excel
Created On: 22-Jan-2009 12:21
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 22-Jan-2009 12:21
User is offline View Users Profile Print this message


Irfaan Jamal

Posts: 30
Joined: 13-Feb-2008

Hello,

If an excel file already exists in a windows location and I want to owerwrite that excel sheet without any confirmation message, how do I do it?

when I use oleMethod(objSheet, "SaveAs", args) excel pops up an confirmation message saying "A File named FILENAME already exists in this location. Do you want to replace it?" with "YES" "NO" and "CANCEL" buttons.

How to get rid of this message?

Thanks & Regards
Irfaan
Report this to a Moderator Report this to a Moderator
 22-Jan-2009 17:01
User is offline View Users Profile Print this message


ron lewis

Posts: 650
Joined: 20-Sep-2004

In dxl there is the hard way and then there is an easy way.

For now I will only tell you the easy way.

Using dxl see if the file exists already -- if it exists then delete the file then execute a saveas.

If this isn't sufficient for you then ask for the hard way and I will respond.
Report this to a Moderator Report this to a Moderator
 23-Jan-2009 04:06
User is offline View Users Profile Print this message


Irfaan Jamal

Posts: 30
Joined: 13-Feb-2008

Hi,

Yeah, I am aware of this idea. But this is an indirect way of doing it. Is there a direct way?

I guess it is the hard way which you are talking about. :-)

Irfaan
Report this to a Moderator Report this to a Moderator
 23-Jan-2009 14:41
User is offline View Users Profile Print this message


ron lewis

Posts: 650
Joined: 20-Sep-2004

Don't you love someone that is a purist and loves to do things the hard way. I actually harder method but after thinking about the question, I cam up with the easier solution.

Convert the following vba to dxl syntax to silence Excel messages.

objExcel.DisplayAlerts = false

Edited: 23-Jan-2009 at 15:01 by ron lewis
Report this to a Moderator Report this to a Moderator
 23-Jan-2009 14:44
User is offline View Users Profile Print this message


Dennis Lockshine

Posts: 113
Joined: 7-Apr-2003

You can use the "DisplayAlerts" property of the Excel application object. From the MSDN website:

When using the SaveAs method for workbooks to overwrite an existing file, the 'Overwrite' alert has a default of 'No', while the 'Yes' response is selected by Excel when the DisplayAlerts property is set equal to True.


So your code would need to change to something like this, replacing 'objExcel' with the variable that represents the Excel application in your code:

olePut(objExcel, "DisplayAlerts", false)
oleMethod(objSheet, "SaveAs", args)
olePut(objExcel, "DisplayAlerts", true)

-Dennis
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 0 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 0 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.