06-25-2012, 03:08 AM
Join Date: Jun 2012
Error 4248 from file on intranet
Hello. Im new here and a newbie on VB.
I got like 100+ documents (word 2007 and excel 2007) and the main thing will be, to have the opportunity to choose a footer when you open a doc from a popup. im this case, three different offices.
All documents will be on our intranet.
But... When I'm trying to open a file (from intranet), Im getting error 4248 - "The command is not avaliable because no document is open".
But it works when im open it direct from our server.
What is wrong with my code below?
This is my code:
Private Sub Document_New()
Private Sub Document_Open()
Application.ScreenUpdating = False
Dim Rng As Range, Str As String, Fld As Field, i As Long
i = CLng(InputBox("Which Office?" & vbCr & "1: Gothenburg, 2: Stockholm, 3: Malmö"))
If i = 0 Or i > 3 Then Exit Sub
Set Rng = .Range.Characters.First
For Each Fld In .Range.Fields
If .Type = wdFieldQuote Then
Set Rng = Fld.Result
Select Case i
Str = "Gothenburg AB, Tel 010-123456, www.gothenburg.com"
Str = "Stockholm AB, Tel 010-123456, www.stockholm.com"
Str = "Malmö AB, Tel 010-123456,www.malmö.com"
Set Fld = ActiveDocument.Fields.Add(Range:=Rng, Type:=wdFieldQuote, _
Text:="""" & Str & """", PreserveFormatting:=False)
Set Fld = Nothing: Set Rng = Nothing
Application.ScreenUpdating = True
Last edited by Flyguy; 06-25-2012 at 04:12 AM.