Results 1 to 10 of 10
  1. #1
    Lounger
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Permission Denied When Deleting Shapes (Word 2003)

    I'm trying to delete buttons (but not other shapes) from documents prior to merging them into a report.

    The document is Unprotected, but when I try to delete the particular shapes -
    ===========================================
    ' Dim myShape As Shape
    ' With ActiveDocument
    ' For Each myShape In .Shapes
    ' If myShape.Name = "Control 9" Or _
    ' myShape.Name = "Control 10" Or _
    ' myShape.Name = "Control 11" Then
    ' myShape.Delete
    ' End If
    ' Next myShape
    ' End With
    ====================
    I get a Run-time Error '70' - Permission Denied message when I find the appropriate shape.

    Any suggestions?

    Thanks,
    Al

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Permission Denied When Deleting Shapes (Word 2003)

    Can you delete the button manually?

  3. #3
    Lounger
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Permission Denied When Deleting Shapes (Word 2003)

    Hans -

    Hello...

    Yes, if I disable Macros.
    The document calls a form containing the following code
    I am using to
    1) open all of the like documents in a folder
    2) strip out the particular buttons, and
    3) save the documents
    so they can be merged into a single report.
    ===========================================

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" & strComputer & "rootcimv2")


    strCancelIndicator = "N"
    Me.Hide

    Set FileList = objWMIService.ExecQuery _
    ("ASSOCIATORS OF {Win32_Directory.Name='c:ProjectDashboards'} Where " _
    & "ResultClass = CIM_DataFile")

    For Each objFile In FileList
    Documents.Open FileName:=(objFile.Name)
    '================================================= ========
    ' 1 - Take the focus of the buttons so they can be deleted'
    ' 2 - Be sure the document is unProtected. '
    ' 3 - Save the document to finalize the removal of the '
    ' buttons before sent to PMO mailbox. '
    ' '
    ActiveDocument.txtDate.Select

    If ActiveDocument.ProtectionType <> wdNoProtection Then
    ActiveDocument.Unprotect
    End If

    Dim myShape As Shape
    With ActiveDocument
    For Each myShape In .Shapes
    If myShape.Name = "Control 9" Or _
    myShape.Name = "Control 10" Or _
    myShape.Name = "Control 11" Then
    myShape.Delete
    End If
    Next myShape
    End With

    ActiveDocument.Close SaveChanges:=wdSaveChanges
    Next
    ================================

    Thanks for your patience,
    Al

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Permission Denied When Deleting Shapes (Word 2003)

    I'm afraid I don't know what could cause this error. Could you attach a small sample document that demonstrates the problem? You can remove most or all of the text from the document.

  5. #5
    Lounger
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Permission Denied When Deleting Shapes (Word 2003)

    Hans -

    I

  6. #6
    Lounger
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Permission Denied When Deleting Shapes (Word 2003)

    Hans -
    Here is Document 2... the problem child.

    Thanks,
    Al

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Permission Denied When Deleting Shapes (Word 2003)

    My impression is that the document is corrupted. It behaves very strangely - when I tried to resize the label to see the entire caption, Word crashed. I'd create it again from scratch.

  8. #8
    Lounger
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Permission Denied When Deleting Shapes (Word 2003)

    Hans -

    After much trial and error I've discovered the following -

    I re-created the document and moved and copied it to a test drive... and the pre-merge strip works in both cases.
    However, if I open the document and save it, the pre-merge strip throws the error.

    So... since one of the processes opens and renames the file to a standard naming convention, that has been causing the problem.

    Now all I have to do is to figure out
    a) what does the saving do to mess up the document and/or
    [img]/forums/images/smilies/cool.gif[/img] figure out how to manipulate the document to rename it without going through an actual; open/saveas.... maybe some code to copy/rename rather than open/saveas.

    I'll keep trying and let you now what I find out.

    Thanks for all off your help,
    Al

  9. #9
    Lounger
    Join Date
    Jun 2007
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Permission Denied When Deleting Shapes (Word 2003)

    Hans -

    I got it to work properly...!

    1) In the PreMerge-Strip doc, I placed
    WordBasic.DisableAutoMacros 1 'Disables auto macros"
    before Opening the Dashboard document from which I want to delete the controls,

    2) .Delete'd the controls, then

    3) placed WordBasic.DisableAutoMacros 0" 'Enables auto macros
    after Closing the document.

    The documents have the controls stripped and saved with no problems.

    Thanks again for all of your help,
    Al

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Permission Denied When Deleting Shapes (Word 2003)

    Glad you found a solution! This was a tough one!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •