Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

add a second workbook to Excel

$
0
0

$erroractionpreference = “SilentlyContinue” 

$a = New-Object -comobject Excel.Application 

$a.visible = $True

$b = $a.Workbooks.Add() 

$c = $b.Worksheets.Item(1)

$c.Cells.Item(1,1) = “Computer Name” 

$c.Cells.Item(1,2) = “OS Version” 

$c.Cells.Item(1,3) = “IP vLan” 

$c.Cells.Item(1,4) = “Description” 

$c.Cells.Item(1,5) = “Model” 

$d = $c.UsedRange 

$d.Interior.ColorIndex = 37   

$d.Font.ColorIndex = 1       

$d.Font.Bold = $True 

$d.EntireColumn.AutoFit()

$intRow = 2

 

The above code works but how do I make it create a second workbook (SHEET2)?   I've played around with this code but I've yet to have it create a sheet2.

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles