Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Uwe Uwe is offline
external usenet poster
 
Posts: 9
Default error 70 permission denied in excel

I have a bit of code that tries to cleat some entries from a sheet if they
are more than 10 days old. Some rows have comments and a small image that
does not delete when you delete a row. I am trying to select it and delete
it. When the select is executed I get the error message.
For r = xlSheet.Cells(xlSheet.Rows.Count, 1).End(xlUp).Row To 2 Step -1
If DateDiff("d", xlSheet.Cells(r, 1), Now()) 10 Then
xlSheet.Range("G" & Trim(Str(r))).Select
If Not xlSheet.Range("G" & Trim(Str(r))).Comment Is Nothing
Then
xlSheet.Shapes.Range(xlSheet.Shapes.Count).Select
xlSheet.Shapes.Range(xlSheet.Shapes.Count).Delete
End If
xlSheet.Rows(r).EntireRow.Delete
End If
Next r
--
Thanks,
Uwe
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default error 70 permission denied in excel

Selecting the shape doesn't seem to be important in your code. What happens if
you just delete that line.

When I want to delete shapes in certain rows, I'll just check to see if it's in
that row.

And to make matters worse, comments are shapes, autofilter arrows are
shapes...it can get ugly really fast.

Ron de Bruin has some notes that you may want to review.
http://www.rondebruin.nl/controlsobjectsworksheet.htm

But this is how I would start:

Option Explicit
Sub testme()

Dim xlSheet As Worksheet
Dim myShape As Shape
Dim myRow As Long

Set xlSheet = Worksheets("Sheet1")

With xlSheet
For myRow = .Cells(.Rows.Count, "A").End(xlUp).Row To 2 Step -1
If Date - .Cells(myRow, "A").Value 10 Then
If .Cells(myRow, "G").Comment Is Nothing Then
'do nothing
Else
'loop through the shapes
For Each myShape In .Shapes
If myShape.Type = msoComment Then
'skip it
Else
If myShape.TopLeftCell.Row = myRow Then
myShape.Delete
'if there's only one possible non-comment
'shape per row, then get out.
Exit For
End If
End If
Next myShape
End If
.Rows(myRow).Delete
End If
Next myRow
End With
End Sub

Some comments.

DateDiff using "d" is the same as a simple subtraction. But I did drop the time
from my subtraction--you used Now and I used Date.

VBA is very forgiving.

You don't need: xlSheet.Range("G" & Trim(Str(r)))
You could use: xlSheet.Range("G" & r)

Personally, I find xlsheet.cells(r,"G") just as nice

And by using With/End With, I can avoid having to type XLSheet on all those
lines.

and
xlsheet.rows(r).entirerow.delete
is equivalent to
xlsheet.rows(r).delete





Uwe wrote:

I have a bit of code that tries to cleat some entries from a sheet if they
are more than 10 days old. Some rows have comments and a small image that
does not delete when you delete a row. I am trying to select it and delete
it. When the select is executed I get the error message.
For r = xlSheet.Cells(xlSheet.Rows.Count, 1).End(xlUp).Row To 2 Step -1
If DateDiff("d", xlSheet.Cells(r, 1), Now()) 10 Then
xlSheet.Range("G" & Trim(Str(r))).Select
If Not xlSheet.Range("G" & Trim(Str(r))).Comment Is Nothing
Then
xlSheet.Shapes.Range(xlSheet.Shapes.Count).Select
xlSheet.Shapes.Range(xlSheet.Shapes.Count).Delete
End If
xlSheet.Rows(r).EntireRow.Delete
End If
Next r
--
Thanks,
Uwe


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
Uwe Uwe is offline
external usenet poster
 
Posts: 9
Default error 70 permission denied in excel

Actually I think I know the issue. I have a cell with a comment that has the
small red triangle in the corner. That cell also has a small image (Inserted
as a picture) the reason for the error is that it's trying to select the red
triangle, what I want is to select the image because the image does not
delete when you delete a row.
I know there are 600+ shapes, but how do I identify the image in the cell
that I'm trying to delete?
--
Thanks,
Uwe


"Dave Peterson" wrote:

Selecting the shape doesn't seem to be important in your code. What happens if
you just delete that line.

When I want to delete shapes in certain rows, I'll just check to see if it's in
that row.

And to make matters worse, comments are shapes, autofilter arrows are
shapes...it can get ugly really fast.

Ron de Bruin has some notes that you may want to review.
http://www.rondebruin.nl/controlsobjectsworksheet.htm

But this is how I would start:

Option Explicit
Sub testme()

Dim xlSheet As Worksheet
Dim myShape As Shape
Dim myRow As Long

Set xlSheet = Worksheets("Sheet1")

With xlSheet
For myRow = .Cells(.Rows.Count, "A").End(xlUp).Row To 2 Step -1
If Date - .Cells(myRow, "A").Value 10 Then
If .Cells(myRow, "G").Comment Is Nothing Then
'do nothing
Else
'loop through the shapes
For Each myShape In .Shapes
If myShape.Type = msoComment Then
'skip it
Else
If myShape.TopLeftCell.Row = myRow Then
myShape.Delete
'if there's only one possible non-comment
'shape per row, then get out.
Exit For
End If
End If
Next myShape
End If
.Rows(myRow).Delete
End If
Next myRow
End With
End Sub

Some comments.

DateDiff using "d" is the same as a simple subtraction. But I did drop the time
from my subtraction--you used Now and I used Date.

VBA is very forgiving.

You don't need: xlSheet.Range("G" & Trim(Str(r)))
You could use: xlSheet.Range("G" & r)

Personally, I find xlsheet.cells(r,"G") just as nice

And by using With/End With, I can avoid having to type XLSheet on all those
lines.

and
xlsheet.rows(r).entirerow.delete
is equivalent to
xlsheet.rows(r).delete





Uwe wrote:

I have a bit of code that tries to cleat some entries from a sheet if they
are more than 10 days old. Some rows have comments and a small image that
does not delete when you delete a row. I am trying to select it and delete
it. When the select is executed I get the error message.
For r = xlSheet.Cells(xlSheet.Rows.Count, 1).End(xlUp).Row To 2 Step -1
If DateDiff("d", xlSheet.Cells(r, 1), Now()) 10 Then
xlSheet.Range("G" & Trim(Str(r))).Select
If Not xlSheet.Range("G" & Trim(Str(r))).Comment Is Nothing
Then
xlSheet.Shapes.Range(xlSheet.Shapes.Count).Select
xlSheet.Shapes.Range(xlSheet.Shapes.Count).Delete
End If
xlSheet.Rows(r).EntireRow.Delete
End If
Next r
--
Thanks,
Uwe


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
Uwe Uwe is offline
external usenet poster
 
Posts: 9
Default error 70 permission denied in excel

Thank you - My earlier reply was before I read the entire response. I'll
implement your code and I'm sure it will work.
--
Thanks,
Uwe


"Dave Peterson" wrote:

Selecting the shape doesn't seem to be important in your code. What happens if
you just delete that line.

When I want to delete shapes in certain rows, I'll just check to see if it's in
that row.

And to make matters worse, comments are shapes, autofilter arrows are
shapes...it can get ugly really fast.

Ron de Bruin has some notes that you may want to review.
http://www.rondebruin.nl/controlsobjectsworksheet.htm

But this is how I would start:

Option Explicit
Sub testme()

Dim xlSheet As Worksheet
Dim myShape As Shape
Dim myRow As Long

Set xlSheet = Worksheets("Sheet1")

With xlSheet
For myRow = .Cells(.Rows.Count, "A").End(xlUp).Row To 2 Step -1
If Date - .Cells(myRow, "A").Value 10 Then
If .Cells(myRow, "G").Comment Is Nothing Then
'do nothing
Else
'loop through the shapes
For Each myShape In .Shapes
If myShape.Type = msoComment Then
'skip it
Else
If myShape.TopLeftCell.Row = myRow Then
myShape.Delete
'if there's only one possible non-comment
'shape per row, then get out.
Exit For
End If
End If
Next myShape
End If
.Rows(myRow).Delete
End If
Next myRow
End With
End Sub

Some comments.

DateDiff using "d" is the same as a simple subtraction. But I did drop the time
from my subtraction--you used Now and I used Date.

VBA is very forgiving.

You don't need: xlSheet.Range("G" & Trim(Str(r)))
You could use: xlSheet.Range("G" & r)

Personally, I find xlsheet.cells(r,"G") just as nice

And by using With/End With, I can avoid having to type XLSheet on all those
lines.

and
xlsheet.rows(r).entirerow.delete
is equivalent to
xlsheet.rows(r).delete





Uwe wrote:

I have a bit of code that tries to cleat some entries from a sheet if they
are more than 10 days old. Some rows have comments and a small image that
does not delete when you delete a row. I am trying to select it and delete
it. When the select is executed I get the error message.
For r = xlSheet.Cells(xlSheet.Rows.Count, 1).End(xlUp).Row To 2 Step -1
If DateDiff("d", xlSheet.Cells(r, 1), Now()) 10 Then
xlSheet.Range("G" & Trim(Str(r))).Select
If Not xlSheet.Range("G" & Trim(Str(r))).Comment Is Nothing
Then
xlSheet.Shapes.Range(xlSheet.Shapes.Count).Select
xlSheet.Shapes.Range(xlSheet.Shapes.Count).Delete
End If
xlSheet.Rows(r).EntireRow.Delete
End If
Next r
--
Thanks,
Uwe


--

Dave Peterson

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
error 70 - Permission denied MT Excel Programming 1 May 8th 05 07:20 AM
Run time error 70 permission denied Sachin[_4_] Excel Programming 0 August 21st 04 05:07 AM
Permission Denied Error 70 Tom Ogilvy Excel Programming 0 August 3rd 04 04:56 PM
Runtime error Permission Denied Todd Huttenstine[_2_] Excel Programming 1 December 29th 03 10:46 PM
Error Msg: Permission to use object denied A. Nguyen Excel Programming 4 July 14th 03 09:05 PM


All times are GMT +1. The time now is 09:19 AM.

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"