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. This is due to the VBA code not finding ActiveDocument.
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
'Enable Editing' problem when viewing doc as attachment
-
- 5StarLounger
- Posts: 656
- Joined: 18 Feb 2010, 14:26
'Enable Editing' problem when viewing doc as attachment
You do not have the required permissions to view the files attached to this post.
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: 'Enable Editing' problem when viewing doc as attachment
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
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
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- 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
Andy's explanation looks plausible to me. You could test for a document being open:
If Documents.Count = 0 Then Exit Sub
If Documents.Count = 0 Then Exit Sub
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: 'Enable Editing' problem when viewing doc as attachment
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.
-
- 5StarLounger
- Posts: 656
- Joined: 18 Feb 2010, 14:26
Re: 'Enable Editing' problem when viewing doc as attachment
Just tried it but documents.count is actually 1.HansV wrote:Andy's explanation looks plausible to me. You could test for a document being open:
If Documents.Count = 0 Then Exit Sub
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: 'Enable Editing' problem when viewing doc as attachment
Code: Select all
Private Sub Document_New() 'or Open if applicable
Application.OnTime When:=Now + TimeValue("00:00:05"), _
Name:="Macro1"
End Sub
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.
-
- 5StarLounger
- Posts: 656
- Joined: 18 Feb 2010, 14:26
Re: 'Enable Editing' problem when viewing doc as attachment
Thanks but this could be problematic as well, how long an interval since all document sizes are different.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.
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: 'Enable Editing' problem when viewing doc as attachment
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.
-
- 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
I'd recommed instructing users NEVER to open attachments directly. Always save to disk, then open the saved version.
Best wishes,
Hans
Hans
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: 'Enable Editing' problem when viewing doc as attachment
The better approachHansV wrote:I'd recommed instructing users NEVER to open attachments directly. Always save to disk, then open the saved version.
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.
-
- 5StarLounger
- Posts: 656
- Joined: 18 Feb 2010, 14:26
Re: 'Enable Editing' problem when viewing doc as attachment
Now you are talking Hans - words of wisdom.HansV wrote:I'd recommed instructing users NEVER to open attachments directly. Always save to disk, then open the saved version.
Unfotunately, no one listens to me. At the moment thinking of removing protected view but may have to have a rethink on that one.
-
- Administrator
- Posts: 12632
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: 'Enable Editing' problem when viewing doc as attachment
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