Run time error '4248', this command is not available because no document is open in word

vbvba

New Member
Joined
May 25, 2012
Messages
34
Hi Guys,

I have a template which is there in Templates folder of C:\Program files(x86)\Microsoft Office\Templates\London folder.
Now when I click the icon from word ribbon which i have created to initialize the signature template from the London folder, it should pop up Signature user form with word document in background so the user can enter their details.
But, I receive a run time error '4248', this command is not available because no document is open.
i found few articles where they have written code to trap the error and then initialize the template.below is one of the code form the source link WD2000: Error Message: "Run-time error '4248'; 'This command is not available because no document is open.'"

Code:
Sub ChangeDocProperties()
On Error GoTo ErrHandler
ActiveDocument.BuiltInDocumentProperties("Title") = "My Title"
Exit Sub
ErrHandler:
If Err <> 0 Then
 'Add a document.
 Documents.Add
 'Clear the error.
 Err.Clear
'Execute the code that caused the error.
Resume
End If
End Sub

One more code is updated for the same
Code:
F
Function IsWordDocOpen(sWordDocFullName As String) as Boolean 
    Dim wdApp as Object ' Late Binding - who cares? 
    Dim wdDoc as Object 
    IsWordDocOpen = False 
    On Error Resume Next 
    '- try to get Word application 
    Set wdApp = GetObject(, "Word.Application") 
    If Err.Number = 4248 Then ' Word is not open 
        Exit Function 
    End If 
    On Error GoTo 0 
    For Each wdDoc in wdApp.Documents 
        If wddoc.FullName = sWordDocFullName Then 
            IsWordDocOpen = True 
            Exit Function 
        End If 
    Next 
End Function

Now, I would like to clarify where to place this code in word document ?
Is it in ThisDocument of the Word document or in Modules of template macro code ?
Also please confirm whether the above code will initialize the template user form after the error is trapped and cleared ?
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top