PC Review


Reply
Thread Tools Rate Thread

Deleting pasted HTML controls with Javascript

 
 
lisa.liel@gmail.com
Guest
Posts: n/a
 
      24th Jun 2008
Okay, this is an odd problem. I have an export function that copies a
table from HTML and pastes it into an Excel spreadsheet. The problem
is, the table has checkboxes in it, so when I paste, I get shapes in
the spreadsheet. And I want to delete them from the same webpage that
I used to copy the HTML over.

I can run a macro in Excel that says:

For i = ActiveSheet.Shapes.Count To 1 Step -1
ActiveSheet.Shapes(i).Delete
Next i

This works fine. But when I try and do it from Excel, it crashes and
burns:

for (i = objWorksheet.Shapes.Count; i >= 1; i--){
objWorksheet.Shapes(i).Delete;
}

If I do alert(objWorksheet.Shapes(i).Name), it gives me the name of
each object, so I know I'm accessing the objects. I can even set an
object equal to the shape, but when I try and do .Delete, it craps
out.

Has anyone run into something like this? I don't know if it's some
sort of wonky Microsoft security thing, or if someone simply forgot to
include this method when they made the COM wrapper, but it's driving
me nuts. There must be some way to get rid of those things from the
javascript, no?

Thanks in advance,
Lisa
 
Reply With Quote
 
 
 
 
Tim Williams
Guest
Posts: n/a
 
      25th Jun 2008
Some things not clear:

1. Where is your export function running? How is the HTML copied to XL ?
2. You say "from Excel" but then show javascript code - where is this
running ? Did you mean from outside of XL ?

Maybe:

objWorksheet.Shapes(i).Delete(); // in loop

or just

objWorksheet.Shapes.Delete() //without the loop


Tim

<(E-Mail Removed)> wrote in message
news:8c942d87-64c4-43d2-bb6c-(E-Mail Removed)...
> Okay, this is an odd problem. I have an export function that copies a
> table from HTML and pastes it into an Excel spreadsheet. The problem
> is, the table has checkboxes in it, so when I paste, I get shapes in
> the spreadsheet. And I want to delete them from the same webpage that
> I used to copy the HTML over.
>
> I can run a macro in Excel that says:
>
> For i = ActiveSheet.Shapes.Count To 1 Step -1
> ActiveSheet.Shapes(i).Delete
> Next i
>
> This works fine. But when I try and do it from Excel, it crashes and
> burns:
>
> for (i = objWorksheet.Shapes.Count; i >= 1; i--){
> objWorksheet.Shapes(i).Delete;
> }
>
> If I do alert(objWorksheet.Shapes(i).Name), it gives me the name of
> each object, so I know I'm accessing the objects. I can even set an
> object equal to the shape, but when I try and do .Delete, it craps
> out.
>
> Has anyone run into something like this? I don't know if it's some
> sort of wonky Microsoft security thing, or if someone simply forgot to
> include this method when they made the COM wrapper, but it's driving
> me nuts. There must be some way to get rid of those things from the
> javascript, no?
>
> Thanks in advance,
> Lisa



 
Reply With Quote
 
lisa.liel@gmail.com
Guest
Posts: n/a
 
      26th Jun 2008
The function is a javascript one in a webpage that's an ASP.NET page.
Basically, the ASP creates the table, and the user can click a button
and export the table to an Excel spreadsheet. Then I format the
spreadsheet as I like from the javascript. It works like a charm,
except for the deleting.

But thank you. You actually did solve it for me. My problem was that
I'd used:

objWorksheet.Shapes.Delete;

I should have used:

objWorksheet.Shapes.Delete();

It was the parentheses that did it.

Thanks for your help.

Lisa


On Jun 24, 9:07*pm, "Tim Williams" <timjwilliams at gmail dot com>
wrote:
> Some things not clear:
>
> 1. Where is your export function running? How is the HTML copied to XL ?
> 2. You say "from Excel" but then show javascript code - where is this
> running ? *Did you mean from outside of XL ?
>
> Maybe:
>
> objWorksheet.Shapes(i).Delete(); *// in loop
>
> or just
>
> objWorksheet.Shapes.Delete() *//without the loop
>
> Tim
>
> <lisa.l...@gmail.com> wrote in message
>
> news:8c942d87-64c4-43d2-bb6c-(E-Mail Removed)...
>
>
>
> > Okay, this is an odd problem. *I have an export function that copies a
> > table from HTML and pastes it into an Excel spreadsheet. *The problem
> > is, the table has checkboxes in it, so when I paste, I get shapes in
> > the spreadsheet. *And I want to delete them from the same webpage that
> > I used to copy the HTML over.

>
> > I can run a macro in Excel that says:

>
> > For i = ActiveSheet.Shapes.Count To 1 Step -1
> > ActiveSheet.Shapes(i).Delete
> > Next i

>
> > This works fine. *But when I try and do it from Excel, it crashes and
> > burns:

>
> > for (i = objWorksheet.Shapes.Count; i >= 1; i--){
> > objWorksheet.Shapes(i).Delete;
> > }

>
> > If I do alert(objWorksheet.Shapes(i).Name), it gives me the name of
> > each object, so I know I'm accessing the objects. *I can even set an
> > object equal to the shape, but when I try and do .Delete, it craps
> > out.

>
> > Has anyone run into something like this? *I don't know if it's some
> > sort of wonky Microsoft security thing, or if someone simply forgot to
> > include this method when they made the COM wrapper, but it's driving
> > me nuts. *There must be some way to get rid of those things from the
> > javascript, no?

>
> > Thanks in advance,
> > Lisa- Hide quoted text -

>
> - Show quoted text -


 
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
RE: pasted HTML text disappears =?Utf-8?B?c3Vuc2xpZ2h0?= Microsoft Excel Misc 0 9th Jan 2007 06:50 AM
HTML Table pasted to Excel =?Utf-8?B?Sm9zaCBPLg==?= Microsoft Excel Misc 2 19th Oct 2005 06:52 PM
Re: Problems with pasted HTML data David McRitchie Microsoft Excel Programming 1 25th Jun 2004 04:12 PM
difference between HTML controls, HTML server controls , ASP.Net controls? Hari Microsoft Dot NET 1 3rd Jan 2004 11:11 AM
Text From HTML not getting pasted. jegarajagokul Microsoft Word New Users 0 1st Dec 2003 08:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:22 PM.