Error 4248 No Document Open
Contents |
be down. Please try the request again. Your cache administrator is webmaster. Generated Mon, 10 Oct 2016 00:01:38 GMT by s_wx1094 (squid/3.5.20)
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about
Run Time Error 4605 Visual Basic
hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges
Run-time Error '5941' Application-defined Or Object-defined Error
Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. run-time error 4605 excel Join them; it only takes a minute: Sign up Normal.dotm macro throws error opening protected document up vote 1 down vote favorite I added the following macro to my Normal.dotm for Word 2010: Sub AutoOpen() ' ' AutoOpen http://answers.microsoft.com/en-us/msoffice/forum/msoffice_word-mso_other/i-have-multiple-word-documents-on-i-get-a-error/c0b45ead-4c32-4da3-afb2-96fc8b690f11 Macro ' ' Dim aStory As Range Dim aField As Field For Each aStory In ActiveDocument.StoryRanges For Each aField In aStory.Fields aField.Update Next aField Next aStory ' set document as unchanged (prevents save dialog popping up when closing) - further changes will set this back ActiveDocument.Saved = True End Sub Now when I open some documents in Word 2010, I get the following error message: Run-time error '4248' This command is not available because no document is open http://stackoverflow.com/questions/12037139/normal-dotm-macro-throws-error-opening-protected-document So far this seems to occur for files that are opened in Protected view (e.g. files downloaded from the internet, or email attachments) - if I switch off Protected view in the Trust Centre the problem goes away. ms-word word-vba share|improve this question edited Dec 19 '15 at 18:27 Community♦ 11 asked Aug 20 '12 at 11:52 dunxd 4702926 add a comment| 1 Answer 1 active oldest votes up vote 3 down vote Microsoft wrote a blog entry on detecting whether Protected Mode is running from within a macro. This shows that the value of Application.ActiveProtectedViewWindow is Nothing when a document is not in Protected View. So wrapping the macro functions that refer to ActiveDocument in If statements checking for this will prevent those functions from running when the document is in Protected view. The above script becomes: Sub AutoOpen() ' ' AutoOpen Macro ' ' Dim aStory As Range Dim aField As Field ' Check that document is not in Protected View before doing anything If Application.ActiveProtectedViewWindow Is Nothing Then For Each aStory In ActiveDocument.StoryRanges For Each aField In aStory.Fields aField.Update Next aField Next aStory ' set document as unchanged (prevents save dialog popping up when 'closing) - further changes will set this back ActiveDocument.Saved = True End If End Sub share|improve this answer edited Aug 20 '12 at 12:22 answered Aug 20 '12 at 12:01 dunxd 4702926 add a comment|
because no document is open. Error code 4248 If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To http://www.vbforums.com/showthread.php?612343-RESOLVED-This-command-is-not-available-because-no-document-is-open-Error-code-4248 start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 4 of 4 Thread: [RESOLVED] This command is not available because no document is open. Error code 4248 Tweet Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Apr 23rd, 2010,10:41 AM #1 but43r View Profile View Forum Posts Thread Starter New Member Join Date Apr 2010 Posts 3 time error [RESOLVED] This command is not available because no document is open. Error code 4248 Hi, I have a web application that used to be hosted on Server 2003 and IIS6, recently the web application was moved to Server 2008 R2 and IIS7.5 and now is just wont work. I just give me this error. This command is not available because no document is open.4248 Here is the code that causes it to throw that error and I have run time error marked specific line with ----> where it crashes. Dim wdApp ' Create the word object Set wdApp = Server.CreateObject("Word.Application") if Err.number <> 0 Then nErr = 1 szErr = " Error creating the Word Object " & Err.Description Exit sub End if ' Open the Template document wdApp.Documents.Open sSourcePath if Err.number <> 0 Then nErr = 1 szErr = " Error Opening the template document " & sSourcePath & " " & Err.Description Exit sub End iF Dim arrTags, arrValues Dim iLoop ' Organise the Strings arrTags = Split(sTags, ", ") arrValues = Split(sValues, " | ") Loop over the strings pulling out the assigned values For iLoop = 0 To UBound(arrTags) -----> wdApp.ActiveDocument.Content.Find.Execute arrTags(iLoop), , True, , _ , , , , , arrValues(iLoop), 2 if Err.number <> 0 Then nErr = 1 szErr = " Error while looping over the tags and values " & Err.Description & Err.Number Exit Sub End If Next ' Apply to the active document wdApp.ActiveDocument.Content.Find.Execute if Err.number <> 0 Then nErr = 1 szErr = " Error calling the execute method on the Active Document " & Err.Description & Err.Number Exit Sub End If ' Save the document wdApp.ActiveDocument.SaveAs sDestPath If Err.number <> 0 Then nErr = 1 szErr = " Error Saving the document " & sDestPath & " " & Err.Description Exit Sub End If ' Close the Document and free the resources wdApp.ActiveDocument.Cl