'Enable Editing' problem when viewing doc as attachment

Robie
5StarLounger
Posts: 656
Joined: 18 Feb 2010, 14:26

'Enable Editing' problem when viewing doc as attachment

Post by Robie »

Another 2010 tantrum.

We have found that attached document to an email when opened are fine but if you 'Enable Editing' then it fails with a VBA error.
18.png
This is due to the VBA code not finding ActiveDocument.
17.png
On the other hand if document is opended from Windows Exploder then it is fine.

The template was created in 2003 but saved as DOTM under 2010.

Thanks.
Robie
You do not have the required permissions to view the files attached to this post.

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: 'Enable Editing' problem when viewing doc as attachment

Post by agibsonsw »

I'm guessing that the MS code that runs when clicking Enable Editing temporarily removes (closes) the ActiveDocument, and at the point when your template code also runs there is no ActiveDocument. (The MS code doesn't so much enable editing as close and re-open an editable version of the document.)

Not sure how you can surmount this, other than by not opening from an attachment. There is a Word option in the Trust Center to not use Protected Mode, but this would have to be chosen by each individual (or globally) and is not recommended.

But I'm sure someone will correct me if I've mis-understood :cheers:
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
HansV
Administrator
Posts: 78654
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: 'Enable Editing' problem when viewing doc as attachment

Post by HansV »

Andy's explanation looks plausible to me. You could test for a document being open:

If Documents.Count = 0 Then Exit Sub
Best wishes,
Hans

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: 'Enable Editing' problem when viewing doc as attachment

Post by agibsonsw »

Editing your code to get around this issue may be problematic. It might be worth considering using a Timer interval to delay your code from running; that is, with a suitable interval to ensure that the MS process has completed.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

Robie
5StarLounger
Posts: 656
Joined: 18 Feb 2010, 14:26

Re: 'Enable Editing' problem when viewing doc as attachment

Post by Robie »

HansV wrote:Andy's explanation looks plausible to me. You could test for a document being open:

If Documents.Count = 0 Then Exit Sub
Just tried it but documents.count is actually 1.

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: 'Enable Editing' problem when viewing doc as attachment

Post by agibsonsw »

Code: Select all

Private Sub Document_New()  'or Open if applicable
    Application.OnTime When:=Now + TimeValue("00:00:05"), _
        Name:="Macro1"
End Sub
..if it helps :cheers:
Last edited by agibsonsw on 16 Dec 2011, 16:50, edited 1 time in total.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

Robie
5StarLounger
Posts: 656
Joined: 18 Feb 2010, 14:26

Re: 'Enable Editing' problem when viewing doc as attachment

Post by Robie »

agibsonsw wrote:Editing your code to get around this issue may be problematic. It might be worth considering using a Timer interval to delay your code from running; that is, with a suitable interval to ensure that the MS process has completed.
Thanks but this could be problematic as well, how long an interval since all document sizes are different.

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: 'Enable Editing' problem when viewing doc as attachment

Post by agibsonsw »

I suppose you could cause the timer to repeat with a short interval, checking each time for an ActiveDocument, with error handling to ensure the code doesn't bail.
Last edited by agibsonsw on 16 Dec 2011, 16:53, edited 1 time in total.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
HansV
Administrator
Posts: 78654
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: 'Enable Editing' problem when viewing doc as attachment

Post by HansV »

I'd recommed instructing users NEVER to open attachments directly. Always save to disk, then open the saved version.
Best wishes,
Hans

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: 'Enable Editing' problem when viewing doc as attachment

Post by agibsonsw »

HansV wrote:I'd recommed instructing users NEVER to open attachments directly. Always save to disk, then open the saved version.
The better approach :clapping:

The question also arises - if it's a template, doesn't it need to be saved somewhere anyway?
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

Robie
5StarLounger
Posts: 656
Joined: 18 Feb 2010, 14:26

Re: 'Enable Editing' problem when viewing doc as attachment

Post by Robie »

HansV wrote:I'd recommed instructing users NEVER to open attachments directly. Always save to disk, then open the saved version.
Now you are talking Hans - words of wisdom. :clapping:

Unfotunately, no one listens to me. :sad: At the moment thinking of removing protected view but may have to have a rethink on that one.

User avatar
StuartR
Administrator
Posts: 12632
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: 'Enable Editing' problem when viewing doc as attachment

Post by StuartR »

I get the same problem when I open Word documents from a secure web page provided by one of my customers. I just ignore the error and carry on working.
StuartR