View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
geekoid geekoid is offline
external usenet poster
 
Posts: 1
Default VSTO removin formulas and email


I could really use some help here.
When the users clicks email (as attachment...) I need to create a cop
of the spread sheet that contains no formulas, only the data that is i
the cells. Delete hidden columns and rows, and then email the copy.

I know how to grab the email event, I can delete the hidden columns an
rows.

I do not know how to create a copy of a sheet that is only the data.

And right now, when I create a copy, the original has it's row
deleted, not the copy and the copy is emailed.
What I have:

Dim xRange As Excel.Range
Dim sname As String = "test"
Dim _cachePath As String = StingerGlobal.Config.InstallPath
Dim stuffToDelete As New ArrayList

Dim hiddenColumns As String = ""
Dim firstColumn As Boolean = True
Dim numColumns As Integer = _sheet.UsedRange.Columns.Count

'create temp copy

Dim tempSheet As Excel.Worksheet

tempSheet = DirectCast(_sheet, Excel.Worksheet)

tempSheet.Copy()
tempSheet.Name = sname
tempSheet.SaveAs(_cachePath & sname & ".xls")
'remove rows&columns
xRange = CType(tempSheet.Cells, Excel.Range)

For x As Integer = 1 To numColumns
Dim currentColumn As Excel.Range
Dim hiddenValue As Boolean
currentColumn = CType(tempSheet.Columns(x), Excel.Range)
hiddenValue = CType(currentColumn.Hidden, Boolean)
If hiddenValue = True Then
stuffToDelete.Add(currentColumn)
End If
Next

For Each col As Excel.Range In stuffToDelete
col.Delete()
Next


Thanks

--
geekoi
-----------------------------------------------------------------------
geekoid's Profile: http://www.msusenet.com/member.php?userid=80
View this thread: http://www.msusenet.com/t-187013486