PC Review


Reply
Thread Tools Rate Thread

Copy/PasteSpecial Not Pasting all Formatting

 
 
=?Utf-8?B?RXJpYyBXZWxsZXI=?=
Guest
Posts: n/a
 
      17th Aug 2007
All,
I am moving the formatting (border, font, cell size, etc) from a cell on one
sheet to a cell on another sheet by using copy and PasteSpecial. It works
fine except there are is a cell that does not get the borders copied. It
consistantly does not copy the borders from cell $K$13.
The code searches the worksheet looking for cells that contain the "<"
character. If it finds one, it copies the formatting to Sheet 1 to Sheet 2.
Here is the code I am using:

objBook = objBooks.Open(objReport.TemplateFileName)
objSheets = objBook.Worksheets()
objSheet = objSheets.Item(1)
objSheet2 = objSheets.Item(2)
objSheet.Name = "Unit Price"

' Look for TAGs in the Template
For I = 1 To 20
For J = 1 To 80
sTemp1 = Convert.ToChar(I + 64) & J.ToString
sTemp2 = objSheet.Range(sTemp1).Value
If Not IsNothing(sTemp2) Then
If sTemp2.Substring(0, 1) = "<" Then
sTag = sTemp2.Substring(1, sTemp2.Length - 2)
range = objSheet.Range(sTemp1)
sTemp3 =
objSheet.Range(sTemp1).MergeArea.Address()
sTemp1 = sTemp3
objSheet.Range(sTemp1).Copy()

objSheet2.Range(sTemp1).PasteSpecial(Microsoft.Office.Interop.Excel.XlPasteType.xlPasteAll)

End If
End If
Next
Next


I am totally stumped!!!
Thanks for your help.

 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      17th Aug 2007
Maybe there are no borders in cell $K$13, but borders in neighbouring cells.

Regards,
Peter T

"Eric Weller" <(E-Mail Removed)> wrote in message
newsC5F5F43-B812-4962-9B95-(E-Mail Removed)...
> All,
> I am moving the formatting (border, font, cell size, etc) from a cell on

one
> sheet to a cell on another sheet by using copy and PasteSpecial. It works
> fine except there are is a cell that does not get the borders copied. It
> consistantly does not copy the borders from cell $K$13.
> The code searches the worksheet looking for cells that contain the "<"
> character. If it finds one, it copies the formatting to Sheet 1 to Sheet

2.
> Here is the code I am using:

<snip>


 
Reply With Quote
 
=?Utf-8?B?RXJpYyBXZWxsZXI=?=
Guest
Posts: n/a
 
      17th Aug 2007
That is not the case. I even put borders on all 4 sides of the cell and it
still did not copy them.

"Peter T" wrote:

> Maybe there are no borders in cell $K$13, but borders in neighbouring cells.
>
> Regards,
> Peter T
>
> "Eric Weller" <(E-Mail Removed)> wrote in message
> newsC5F5F43-B812-4962-9B95-(E-Mail Removed)...
> > All,
> > I am moving the formatting (border, font, cell size, etc) from a cell on

> one
> > sheet to a cell on another sheet by using copy and PasteSpecial. It works
> > fine except there are is a cell that does not get the borders copied. It
> > consistantly does not copy the borders from cell $K$13.
> > The code searches the worksheet looking for cells that contain the "<"
> > character. If it finds one, it copies the formatting to Sheet 1 to Sheet

> 2.
> > Here is the code I am using:

> <snip>
>
>
>

 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      17th Aug 2007
It's difficult to decipher your code and imagine what you might have in
cells, seems some are merged which complicates things.. Normally
Paste:=xlPasteAll should paste all formats including borders. Suggest
recreate you code in VBA, perhaps start with a recorded macro, manually
copy/paste cells in exactly the same order as the logic of your .Net code.

Regards,
Peter T


"Eric Weller" <(E-Mail Removed)> wrote in message
news:12966B4A-A51F-4D02-A7A0-(E-Mail Removed)...
> That is not the case. I even put borders on all 4 sides of the cell and

it
> still did not copy them.
>
> "Peter T" wrote:
>
> > Maybe there are no borders in cell $K$13, but borders in neighbouring

cells.
> >
> > Regards,
> > Peter T
> >
> > "Eric Weller" <(E-Mail Removed)> wrote in message
> > newsC5F5F43-B812-4962-9B95-(E-Mail Removed)...
> > > All,
> > > I am moving the formatting (border, font, cell size, etc) from a cell

on
> > one
> > > sheet to a cell on another sheet by using copy and PasteSpecial. It

works
> > > fine except there are is a cell that does not get the borders copied.

It
> > > consistantly does not copy the borders from cell $K$13.
> > > The code searches the worksheet looking for cells that contain the "<"
> > > character. If it finds one, it copies the formatting to Sheet 1 to

Sheet
> > 2.
> > > Here is the code I am using:

> > <snip>
> >
> >
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
PasteSpecial values pasting formula also?? Raj Microsoft Excel Programming 2 23rd Mar 2009 08:59 AM
Copy/Pasting between documents refuses to change formatting? JAnderson Microsoft Word Document Management 1 21st May 2008 07:58 PM
Copy and PasteSpecial help =?Utf-8?B?Y2hlbWljYWxz?= Microsoft Excel Programming 5 9th Nov 2006 04:31 PM
Maintaining Formatting When Copy and Pasting =?Utf-8?B?SkdNaWxsZXI=?= Microsoft Word Document Management 1 1st Mar 2005 05:29 AM
Copy PasteSpecial Rob van Gelder Microsoft Excel Programming 1 28th Jul 2004 07:59 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:14 AM.