PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[RESOLVED] This command is not available because no document is open. Error code 4248-VBForums
Results 1 to 4 of 4

Thread: [RESOLVED] This command is not available because no document is open. Error code 4248

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    3

    Resolved [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 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.Close
    wdApp.Quit
    Set wdApp = Nothing

    The question is, do I need any libraries or something to run ActiveDocument. The person who wrote the code left the manual to saying that this application need Microsoft Office Server Extensions, I have installed it but application still gives the same error.

    Any help will be appreciated.
    Thanks

  2. #2

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    3

    Re: This command is not available because no document is open. Error code 4248

    Anybody???

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,813

    Re: This command is not available because no document is open. Error code 4248

    as the error is specific try checking the that the path (ssourcepath) is correct on the new server
    it would appear that word has loaded ok, but that the document is not opening and the inline error handling is failing to pick out that the document is not opening

    better code would be to work with a document object, rather than the activedocument
    vb Code:
    1. set mydoc = wdApp.Documents.Open sSourcePath
    2. 'other code
    3. mydoc.Content.Find.Execute arrTags(iLoop), , True, , _
    4. , , , , , arrValues(iLoop), 2
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2010
    Posts
    3

    Re: This command is not available because no document is open. Error code 4248

    Westconn1, Thanks for the reply but your code didn't solve the problem. I was able to solve the problem by creating Desktop folder in C:\Windows\SysWOW64\config\systemprofile\
    and C:\Windows\System32\config\systemprofile\

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width