ASP on Excel COM Object

Discussion in 'C#' started by bsilver10, Jul 10, 2006.

  1. #1
    Hi,

    Can anyone help me with my problem? Where developing Project Management Tool with asp and I need to access an Excel File using ASP.

    Set objExcelA = Server.CreateObject("Excel.Application")
    Set objExcelW = objExcelA.Workbooks.Open(Server.MapPath(".") &
    "\Quality_Management_Sheet(QMS).xls")


    objExcelW.Worksheets(2).Activate
    objExcelW.Worksheets(2).Cells(3, 3).Value = "Hey"
    objExcelW.Worksheets(2).Rows("46:47").Copy
    objExcelW.Worksheets(2).Rows("48").Select
    selection.insert shift=xldown


    objExcelW.SaveAs (Server.MapPath(".") & "\benjotest.xls")


    objExcelA.Application.Quit
    Set objExcelA = nothing

    so far, this is the code i've written, and I have successfully tried this on VB, but the "selection.insert shift=xldown" won't work. I'm trying to select two rows, and insert it in third row. Just like doing "insert copied cells" in excel. I would eally appreciate all the help I could get. Thanks guys!
     
    bsilver10, Jul 10, 2006 IP
  2. iconico

    iconico Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The easiest way to figure out how to do this is record a Macro in Excel and then view the VBS that it generates. You should then be able to use it.

    Oh also I would not do this on a prime-time web app, you're going to really load down your web server. Try using a third party component to write the Excel file.
     
    iconico, Jun 10, 2008 IP