![]() |
Excel Paste and VB.NET
All:
I have a VB.NET application that reads an Excel Template Spreadsheet to get a specific cell's formatting (border, font, size, etc). I want to copy the cell's formatting to another cell. I am using VB.NET and here is the code I am using: range = objSheet.Range("A1", "A1") ' range defined as Excel.range System.Windows.Forms.Clipboard.SetDataObject(range .Cells) ' copy to clipboard objSheet.Range("A20", "A20").Cells.Select() ' objSheet defined as Excel.Sheet objSheet.PasteSpecial() When the PasteSpecial method executes, I get the following error: Err.Number=1004 Err.Desc=Exception from HRESULT: 0x800A03EC. Err.Source=Interop.Excel How can I programitically copy one cell's formatting to another cell? Thanks in advance! Eric Weller |
Excel Paste and VB.NET
Eric.
Just use the Excel Object Model to perform the action. objSheet.Range("C7").Copy objSheet.Range("E7").PasteSpecial Paste:=xlFormats (Or the .Net translation) NickHK "Eric Weller" ... All: I have a VB.NET application that reads an Excel Template Spreadsheet to get a specific cell's formatting (border, font, size, etc). I want to copy the cell's formatting to another cell. I am using VB.NET and here is the code I am using: range = objSheet.Range("A1", "A1") ' range defined as Excel.range System.Windows.Forms.Clipboard.SetDataObject(range .Cells) ' copy to clipboard objSheet.Range("A20", "A20").Cells.Select() ' objSheet defined as Excel.Sheet objSheet.PasteSpecial() When the PasteSpecial method executes, I get the following error: Err.Number=1004 Err.Desc=Exception from HRESULT: 0x800A03EC. Err.Source=Interop.Excel How can I programitically copy one cell's formatting to another cell? Thanks in advance! Eric Weller |
All times are GMT +1. The time now is 01:28 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com