ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Copy Paste Excel by Powershell

    IT Discussion
    2
    3
    656
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • LakshmanaL
      Lakshmana
      last edited by

      I am having the Excel File 1 and Excel File 2 where the contents in the excel file 2 needs to be copied to excel file 1.Whether the copying can be done through the Sheet name ?

      I am having this powershell script to copy but the copying is happening but it should happen according to the sheet present.Can any one help on the same ?

      $excel=new-object -comobject excel.application;
      $excel.visible=$true;
      $SourceWorkBook=$Excel.Workbooks.open("$filelocation");
      $TargetWorkBook=$excel.workBooks.open("filelocation");
      $SourceWorkBook.WorkSheets.item(1).activate();
      $SourceRange=$SourceWorkBook.WorkSheets.item(1).range("A2","O2");
      $SourceRange.copy() | out-null;
      $TargetWorkBook.worksheets.item(1).paste();
      $SourceWorkBook.close($false) # close source workbook w/o saving
      $TargetWorkBook.close($true) # close and save destination workbook
      $excel.quit()

      1 Reply Last reply Reply Quote 0
      • LakshmanaL
        Lakshmana
        last edited by

        Can anyone help on the same if not busy ?

        RoopanKumarR 1 Reply Last reply Reply Quote 0
        • RoopanKumarR
          RoopanKumar @Lakshmana
          last edited by

          @lakshmana sorry am very busy....

          1 Reply Last reply Reply Quote 1
          • 1 / 1
          • First post
            Last post