View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default VSTO removin formulas and email

Hi geekoid

Install my SendMail add-in
http://www.rondebruin.nl/mail/add-in.htm

Or see the code examples on my site
http://www.rondebruin.nl/sendmail.htm


--
Regards Ron de Bruin
http://www.rondebruin.nl



"geekoid" wrote in message ...

I could really use some help here.
When the users clicks email (as attachment...) I need to create a copy
of the spread sheet that contains no formulas, only the data that is in
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 and
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 rows
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.


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