I have a macro that cleans documents (removes page breaks, section breaks, special characters, textboxes, etc.)
When the user runs the macro, they first get a form for them to choose an option or not. The option is to delete pictures and frames or not. It's a checkbox.
If they check the box the macro runs compeltely including the code to remove those objects. If they don't check it, the macro runs partial code.
The problem is that when it gets to the part where it needs to make the Page Setup Portrait, it pops the form again and stops the macro. When I click OK to keep running, the form hangs and doesn't want to respond. Here's the code without the meaningless bulk .
It appears as if the form continues to be the ACTIVE DOCUMENT. It doesn't matter if I hide the form before or after running the code.
Any ideas? Here's the code.
Private Sub cmdOK_Click()
' Verify if the user wants to remove textboxes, frames
' and pictures (signatures and handwritten comments)
If chkRemoveSignatures.Value = True Then
'Run the entire macro with
'additional code to delete mentioned items
‘<<Some code goes here>>
With activedocument.PageSetup
.Orientation = wdOrientPortrait
End With
‘<<Other code goes here>>
'Back to the top of the page
Selection.WholeStory
Selection.StartOf
frmCleanupDocs.Hide
Else
'If FALSE, then run the entire macro without
'the additional code
'Change Page Setup to Portrait
With activedocument.PageSetup
.Orientation = wdOrientPortrait
Selection.WholeStory
Selection.StartOf
frmCleanupDocs.Hide
End Sub
When the user runs the macro, they first get a form for them to choose an option or not. The option is to delete pictures and frames or not. It's a checkbox.
If they check the box the macro runs compeltely including the code to remove those objects. If they don't check it, the macro runs partial code.
The problem is that when it gets to the part where it needs to make the Page Setup Portrait, it pops the form again and stops the macro. When I click OK to keep running, the form hangs and doesn't want to respond. Here's the code without the meaningless bulk .
It appears as if the form continues to be the ACTIVE DOCUMENT. It doesn't matter if I hide the form before or after running the code.
Any ideas? Here's the code.
Private Sub cmdOK_Click()
' Verify if the user wants to remove textboxes, frames
' and pictures (signatures and handwritten comments)
If chkRemoveSignatures.Value = True Then
'Run the entire macro with
'additional code to delete mentioned items
‘<<Some code goes here>>
With activedocument.PageSetup
.Orientation = wdOrientPortrait
End With
‘<<Other code goes here>>
'Back to the top of the page
Selection.WholeStory
Selection.StartOf
frmCleanupDocs.Hide
Else
'If FALSE, then run the entire macro without
'the additional code
'Change Page Setup to Portrait
With activedocument.PageSetup
.Orientation = wdOrientPortrait
Selection.WholeStory
Selection.StartOf
frmCleanupDocs.Hide
End Sub