I am opening an Excel file on my server, and saving it with some other name and then trying to coping the new excel to my local machine.
If i use a simple Excel(without macro but 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 but on reaching to "oWB = oXL.Workbooks.Open(" it hangs up.
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("D:\excelwb\Finance94027_1.xls")
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