[VB.NET & EXCEL] Copy format of cells

Mark

0
Joined
Sep 22, 2003
Messages
29
Hi all!
I have a question :)
Is it possible (with VB.NET) to retrieve the complete format (Category, color, backcolor, size etc.) of a cell?

I need this format information to apply the format of this cell on a entire column of another file.

Thank you in advance.

Mark
 
Mark,

Here is code sample, which may help to solve your task:

Public Sub CopyFormat( _
ByRef rwbkDst As Excel.Workbook, _
ByVal vlngDstColNum As Int32, _
ByRef rwbkSrc As Excel.Workbook, _
ByVal vlngSrcRowNum As Int32, _
ByVal vlngSrcColNum As Int32)
Copy format of rwbkSrc.Worksheets(1).Cell(vlngSrcRowNum,vlngSrcColNum) to
entire column rwbkDst.Column(vlngDstColNum)

rwbkSrc.Worksheets(1).Cells(vlngSrcRowNum, vlngSrcColNum).Copy()
rwbkDst.Worksheets(1).Columns.Item(vlngDstColNum).PasteSpecial( _
Paste:=Excel.Constants.xlFormats, _
Operation:=Excel.Constants.xlNone, _
SkipBlanks:=False, _
Transpose:=False)
End Sub

HTH,
Shamil
 
Back
Top