View Single Post
 
Old January 17th, 2007, 05:21 AM
guptasourav guptasourav is offline
Registered User
 
Join Date: Oct 2006
Location: Pune, Maharastra, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Unable to save Excel with macro on server

I have my Excel file on my server and i want to access it from client i.e open it and save it on the server itself.
If i use a simple Excel it works properly but if i use a macro and make the excel password protected then it does not allow me to open it.


 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