Read Domains Froms Excel File and Open in IE -


i have excel file which looks this:

visted     domains        comments            yahoo.com            google.com            hotmail.com 

all of columns populated.

i trying read domain excel file, open in ie. once it's visited, write 'yes' under 'visited' column.

so far, current script read excel file, , opens in ie. once close current ie window, opens next url.

$excelobject = new-object -comobject excel.application $excelobject.visible = $true $excelobject.displayalerts = $false  $excelfile = "c:\users\muafzal\documents\files\emie\analyzing\list.xlsx"  $workbook = $excelobject.workbooks.open($excelfile) $sheet = $workbook.worksheets.item(1)  $row = [int]2 $domain = @() # beginnt bei 2,1... 3,1... 4,1 {     $domain += $sheet.cells.item($row,2).text ; $row = $row + [int]1 } until (!$sheet.cells.item($row,1).text)  foreach($url in $domain){     #start ie , make visible     $ie = new-object -com "internetexplorer.application"     $ie.visible = $true      #navigate url     $ie.navigate($url)      # output url have been visited text file.     $url |  out-file $done -append      #sleep while ie running     while($ie.visible){             start-sleep -s 1         } } 

i excel document writable, can enter comments website.

i guess "i excel document writeable" mean, ps script should job you.

for that, have solve 2 problems:

  1. how write excel cells:
    first of all, don't want use text property of range object returned $sheet.cells.item($row, 1) because returns displayed if had excel sheet open (and includes hashes if text doesn't fit in cell). more information, see this question.
    guess is, value ok instead of text - , because it's property, can use write information.
    suggestion script move logic foreach loop loop use $row index address visited , comment column.
    set column visited write example:

    do {     $domain += $sheet.cells.item($row,2).text      # (browser magic here!)      # edit exel sheet:     $sheet.cells.item($row, 1).value = 'yes'      $row = $row + [int]1 } until (!$sheet.cells.item($row,1).text) 
  2. how ask user comment?
    can use inputbox method microsoft.visualbasic.interaction class:

    # import microsoft.visualbasic assembly , make # interaction class available in $vbi # add 2 lines top of script [void][system.reflection.assembly]::loadwithpartialname('microsoft.visualbasic') $vbi = [microsoft.visualbasic.interaction] # convenience variable  # ask user comment $comment = $vbi::inputbox("write comment website:", "comment") if ($comment -eq "") {     echo "input box cancelled!" } else {     echo "comment:`t$comment" } 

at end, code might this:

    [void][system.reflection.assembly]::loadwithpartialname('microsoft.visualbasic')     $vbi = [microsoft.visualbasic.interaction] # convenience variable     $excelobject = new-object -comobject excel.application     $excelobject.visible = $true     $excelobject.displayalerts = $false      $excelfile = "c:\users\muafzal\documents\files\emie\analyzing\list.xlsx"      $workbook = $excelobject.workbooks.open($excelfile)     $sheet = $workbook.worksheets.item(1)      $row = [int]2     $domain = @() # beginnt bei 2,1... 3,1... 4,1     {         $domain += $sheet.cells.item($row,2).text           # browser magic here:         #start ie , make visible         $ie = new-object -com "internetexplorer.application"         $ie.visible = $true          #navigate url         $ie.navigate($url)          # output url have been visited text file.         $url |  out-file $done -append          #sleep while ie running         while($ie.visible){                 start-sleep -s 1         }          # ask user comment         $comment = $vbi::inputbox("write comment website:", "comment")         if ($comment -eq "") {             # cancel pressed, maybe revisit later?             $sheet.cells.item($row, 1).value = 'no'         }         else {             # edit exel sheet:             $sheet.cells.item($row, 1).value = 'yes'             $sheet.cells.item($row, 3).value = $comment         }          # next row...         $row = $row + [int]1     } until (!$sheet.cells.item($row,1).text) 

ps: don't have excel installed test code think should work right away. hope wanted know ;)


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -