Unable to open Excel with macro
I want to open an Excel file on server, make some changes to it, save with some other name(on the server itself) and then to open it on my local machine.
If i use a simple Excel(without macro and with password) it works properly but if i use a macro and make the excel password protected then it does not allow me to open it.
It does not give any exception.
The code gets hang at "oXL.Workbooks.Open"
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim oXL As New Excel.Application
Dim oWB, oWBNew As Excel.Workbook
oWB = oXL.Workbooks.Open("\\infpu05019\KnowledgePlanner\ VashiProjects\CX_ADM\PDLC\Coding\SOURCE\CVXGENERAT EEXCELFORTRACK\RESOURCES\Filebag\Finance94027.xls" , , , , "Password")
oWB.SaveAs("\\infpu05019\excelwb\Finance94027_1.xl s")
oWB.Close()
oXL = Nothing
Dim OXL2 As New Excel.Application
Response.Clear()
Response.ContentType = "Application/vnd.ms-excel"
oWBNew = OXL2.Workbooks.Open("\\infpu05019\excelwb\Finance9 4027_1.xls", , , , "Password")
oWBNew.Save()
oWBNew.Close()
OXL2 = Nothing
Catch ex As Exception
Response.Write(ex)
End Try
End Sub
sourav gupta
|