Close Excel file using VB.NET

Hi all,

I need an urgent help here.

I have a excel file which protected by a password, and the excel file itself already have closing code in ThisWorkbook. I need to use VB.NET to read this file, I read successfully open this file using the Workbooks.Open function and pass in the password.

But whenever I want to close this excel file, it will run a dialog box. Is there any possible way to tell the dialog box "yes" or "no" using coding in .NET?

I will put the closing code and my .NET code here.

================================================================================

Comment: Close code in excel 'ThisWorkbook' page.

 Private Sub Workbook_BeforeClose(Cancel As Boolean)
   
On Error Resume Next
   
    MyFileName = "RequestForm" & Worksheets("Request Form").Cells(14, 10) & ".xls"
    a = MsgBox("Request Form will be saved as" &  MyFileName, vbYesNo)
    If a = vbYes Then
        SaveAs ThisWorkbook.Path & "\" & MyFileName
    End If

End Sub

======================================================================

Comment: Code that I use to open excel file using VB.NET

Dim oApp As Excel.Application

Dim oWB As Excel.Workbook

oApp = New Excel.Application

Dim oWS As New Excel.Worksheet

oApp.Visible = False

Dim a As String

oWB = oApp.Workbooks.Open(SaveLocation, False, False, , "abc123")

Try

          oWS = oWB.Worksheets("Request Form")

          a = oWS.Range("B5").Value

Catch ex As Exception

 

Finally

          oWB.Close()

          oWB = Nothing

          oApp.Quit()

          oApp = Nothing

End Try

================================================================== 

 Thanks in advance

Best Regards
AhXue

0
AhXue
6/28/2007 6:36:26 AM
asp.net.getting-started 91979 articles. 3 followers. Follow

2 Replies
522 Views

Similar Articles

[PageSpeed] 45

Hi all,

Anyone have any solutions or comments?

Best Regards
AhXue

0
AhXue
6/29/2007 1:27:35 AM

Which Dialog box its showing?


Thanks & Regards,
Amit Batra

0
Amit_Boyzone
6/29/2007 4:17:17 AM
Reply:

Similar Artilces:

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

Open a excel file show it for 10 sec and then close it by using vb.net
Hello FrinedsI in a problem...The client required to open a number of excel files from a folder, show it for twenty secounds and then close it.It should happen it the cyclic manner.The page should also scroll... You can say i want to make a slide show of the excel sheet...Any kind of help would be great ThanksAmit ...

Creating an Excel file using VB.Net
Just after some help to create an Excel file using VB.Net please. I've had a bit of a hunt around but can't find an exact example of code that I'm after. I'm new to .Net and VB.Net and wanted to create and save records to an EXCEL file. I can translate from C# if need be. Thanks for any help. Hi Amelia99, welcome to the forums. Which version of Excell do you want to use? The latest version (2003) has xml possibilities and you can download a free SDK at the microsoft site that makes it quite easy to use with vs.net 2003. It makes new project templates and one of them is for ex...

how to get data from excel using vb.net
how to get data from excel using vb.net Hi, This article might help: http://authors.aspalliance.com/aldotnet/examples/excel.aspx Regards, How can obtain the sheet's list of a Excel document? here u can find the solution for your problem, mark if as answer if u problem got solved http://lakshmik.blogspot.com/2005/12/how-to-get-excel-data-into-net-dataset.html  Vyas Pentakotauniq_vyas@yahoo.com ...

how can i Get OCX File in .net IDE vb.net/C3
hi all,      How can I generate OCX file in VB.net/c# 2005 that will interact in web pages...?Thanks & Regards,Murthy. Hi murthysrn, As far as I know, VB 2005 and C# 2005 cannot create the project for ocx file. However, I hope the following link will be helpful to you. Creating an ActiveX Control in Visual Studio 2005http://msmvps.com/blogs/pauldomag/archive/2006/08/16/107758.aspxSincerely,Benson YuMicrosoft Online Community Support Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other co...

used a c#.net to vb.net converter and am now getting a syntax error.
ok I used a cool utility at http://www.kamalpatel.net/ConvertCSharp2VB.aspx to convert some c#.net to vb.net and it spit out a bunch of code which almost works but I am getting a syntax error on this line Imports (StreamReader sr = Shadows Function)() As StreamReader(objResponse.GetResponseStream()) I tried it that way and also like Imports (StreamReader sr = Shadows Function)() As StreamReader(objResponse.GetResponseStream()) but either way gave the same error Compiler Error Message: BC30035: Syntax error. Source Error: Line 26: Line ...

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At http://www.WebLogicArts.com/DemoList.aspx there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of develo...

Export GridView as an Excel file using VB.NET
Hi I thought this topic would have been covered to death in Google, but I can't seem to find a simple solution for VB.NET 2.0 (found loads for C#!).  I'm using a simple gridView with an SqlDataSource, and would like a button that when clicked, creates an Excel file which the user can save. Can anyone point me in the right direction? Much appreciatedRichard You can purchase one of many components that will provide this featureYou can write code that will output the file as a CSV file with the .xsl extension then provide a link to the file for download.Or, you can write...

getting and modifying file properties using vb.net
i want my application to retrieve the information from the file`s property window as to when was the file created and when was it modified.... i also want to change these properties  how can i do that using visual basic 2005 classes ????? can some one help??? thanks in advanceaman Use the FileInfo class.Darrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you!...

Problem when get data from Excel file using ADO.NET
THIS IS MY CODE Private Sub GetDataFromXLS() Dim strConn As String Dim objConn As OleDbConnection Dim sql As String strConn = _ "Provider=Microsoft.Jet.OLEDB.4.0; " & _ "Data Source=C:\Data.xls;" & _ "Extended Properties=Excel 8.0;HDR=Yes;" objConn = New OleDbConnection(strConn) objConn.Open() sql = "SELECT ProductCode, ProductName FROM [Data$]" '-Data is name of sheet in Data.xls. Dim objComm...

Need tutorial on creating Excel File using VB.NET
I am trying to create a pipe "|" delimited excel file from my VB.NET application. I did a search and didn't find anything very useful. I will create the pipe delimited text string in code. I just need to write each text string into a different row in a spreadsheet. Then create the .xls file. I have done this previously with a .txt file, but from what I have read this is different when creating a .xls file. Does anyone have any good tutorials for this? Thanks.Don't forget to click "Mark as Answer" on the post that helped you.This credits that member, earns you a po...

converting vb.net 2003 files to vb.net 2005
Hi, i am beginner..i watch videos about vb.net..they made on vs.net 2003 when i wrote these codes in 2005 ,it gives errors..is there any program which convert the code automatically?   thanks,Thanks,Speranza What videos are you talking about?  There are lots of great, up-to-date ASP.NET Videos on this site for free.Darrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you! i am talking about learnvisualstudio.net videos..Thanks,Speranza Speranza:they made on vs.net 2003 when i wrote these codes in 2005 ,it gives errors..is there a...

Error in using a VB.NET .exe file on a computer that hasn't studio net installed
I've create an VB.Net Console Application and i'm trying to make the exe run on another computer that has, let's say windows 98. i've installed on this computer the net framework but it doesn't seem to be enough. what do i have to install also? i've used the following references in my application (if it has anything to do with this): Imports System.IO Imports Excel = Microsoft.Office.Interop.Excel I've also copied on the test computer Microsoft.Office.Interop.Excel.dll in the same folder as the exe file. It doesn't give so many error, but one: Object reference not set to an inst...

how to populate data into a preformatted excel file which contains macros using vb.net
Want to populate data into a preformatted excel file which contains macros using vb.net.Tried to populate data into an normal excel file using interopservices and using the excel COM object.But not able to use the same for populating data into a preformatted excel file which contains macros.Help me on this.Thanks in advance If you are trying to populate the data from SQL Server into MS Excel, you could consider using DTS (Data Transformation Services) and running this as service and calling it from your application.Regards, Narayana Rao Surapaneni Architect | Author | MCSD for .NET | MCSD ...

Web resources about - Close Excel file using VB.NET - asp.net.getting-started

Close to nature forestry - Wikipedia, the free encyclopedia
Close to nature forestry is a theory and practice that takes the forest as an ecosystem and manages it as such. It is based in reduced human ...

Near-close near-front unrounded vowel - Wikipedia, the free encyclopedia
. The IPA symbol is a small capital letter i . The IPA prefers terms "close" and "open" for vowels, and the name of the article follows this. ...

Reviews Site Stik Closes $2.3M Funding Round
Stik , a reviews website for local businesses that taps into Facebook’s social graph and authentication , announced the closing of a $2.3 million ...

NYC and LA get the same threat. LA closes all its schools and the NYC police commissioner, standing next ...
"We see no need whatsoever to take that action here in New York City." Also in the news from New York City, the commissioner of Homeless Services, ...

Sungevity Closes Massive $650 Million Residential Solar Financing Round
California-based solar sales company Sungevity has closed an equity and project financing round worth $650 million. The $650 million financing ...

Palm Springs Fest 2016 To Open With ‘The Fencer’, Close with ‘Last Cab To Darwin’
With just over two weeks to go before the January 1 launch of the 2016 Palm Springs International Film Festival , the organization has announced ...

Trump Wants to 'Close Areas' of the Internet to Fight ISIS -
During last night's GOP debate, Presidential hopeful Donald Trump came up with a novel way of fighting ISIS, suggesting we should be "closing ...

Buccaneers & Rams Close Out Color Rush Uniforms For 2015 Season
The Tampa Bay Buccaneers visit the St. Louis Rams tonight in a fight between two teams seeking long-awaited playoff berths. The Bucs are led ...

Pakistan closes all schools on anniversary of Taliban attack that killed 144 ...
Fox News Pakistan closes all schools on anniversary of Taliban attack that killed 144 ... Fox News Dec. 15, 2015: People rally in connection ...

Latest on School Threats: Indiana Districts Close Schools
Latest on school threats: 2 Indiana school districts cancel classes after getting threats

Resources last updated: 12/18/2015 7:45:13 AM