Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel to Word : Paste specialPaste Link Excel Chart Obj doesn't Makedon Charts and Charting in Excel 0 January 12th 10 08:56 PM
Paste and Paste Special No Longer Working - Excel 2003 SheriJ Excel Discussion (Misc queries) 2 January 15th 09 09:23 PM
In Excel: add a Paste-Special Option to paste IN REVERSE ORDER. stan-the-man Excel Worksheet Functions 7 June 14th 06 08:10 PM
Excel cut/Paste Problem: Year changes after data is copy and paste Asif Excel Discussion (Misc queries) 2 December 9th 05 05:16 PM


All times are GMT +1. The time now is 06:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"