Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel to Word : Paste specialPaste Link Excel Chart Obj doesn't | Charts and Charting in Excel | |||
Paste and Paste Special No Longer Working - Excel 2003 | Excel Discussion (Misc queries) | |||
In Excel: add a Paste-Special Option to paste IN REVERSE ORDER. | Excel Worksheet Functions | |||
Excel cut/Paste Problem: Year changes after data is copy and paste | Excel Discussion (Misc queries) |