Results 1 to 8 of 8

Server stoped ???

  1. #1
    ksor's Avatar
    ksor is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    119

    Server stoped ???

    I use this code for investigating all my word documents in some folders - it works nicely !

    Code:
    Sub loopThroughHyperlinks(strFile As String)
        Dim hl As Integer
        Set doc = Documents.Open(fileName:=strFile, Visible:=False)
        countTotalt = countTotalt + 1
        lblTotalt.Caption = countTotalt
        If doc.Hyperlinks.Count > 0 Then
            For hl = 1 To doc.Hyperlinks.Count
                If InStr(1, doc.Hyperlinks(hl).Address, "http") = 0 Then
                    If xFileExists(doc.Hyperlinks(hl).Address) Then
                    '  just go on
                    End If
                Else
                    If URLExists(doc.Hyperlinks(hl).Address) Then
                        ' just go on
                    Else
                        ' a non-existing local file will be listed here
                        ' because it's defenitely not a URL
                        lstMangler.AddItem doc.Hyperlinks(hl).Address
                        countMangler = countMangler + 1
                        lblMangler.Visible = True
                        lblMangler.Caption = countMangler
                    End If
                End If
            Next hl
        End If
        doc.Close
        Set doc = Nothing
    End Sub
    When the code is finished I can see it leaves a hidden instance of Word running, so if I start it again it run nicely the second time too !

    I don't like having a hidden instance of Word running so I Quit word when I'm throug all the folders and the situation should be like if I never started the program.

    BUT IF I start it again it stops with



    runtime error 462 The remote server machine does not exist or is unavaiable

    at this line:

    Set doc = Documents.Open(fileName:=strFile, Visible:=False)

    How come ?

  2. #2
    Gicu's Avatar
    Gicu is offline Expert
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    856
    Can you show us the complete code (the sub where you manipulate the Word variables, issue the Word.Quit, etc)?
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    377
    I'd venture a guess that you have not declared Option Explicit.

    You have not declared or dimentioned doc, Documents, countTotalt, lblTotalt, countMangler, lblMangler.

  4. #4
    ksor's Avatar
    ksor is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    119
    I just did show you all code concerning Word ... nearly

    I have this in a generel module: Global doc As Word.Document

    I have my Option Explicit too.

    and when all code is finish running I have this - commented out

    Code:
    Private Sub btnTestLinkFil_Click()
        ' Alle mapper med Word-dokumenter lÝbes igennem en efter en
        btnTestLinkFil.Enabled = False
        btnSlet.Enabled = False
        lblVent.Visible = True           ': FlashCtrl True, Me, lblVent, vbRed
        lblTotalt.Visible = True
        ClearListBox lstMangler
        countMangler = 0: countTotalt = 0
        For x = 1 To UBound(docMapper)
            lblVent.Caption = ">>> Vent: Test af mappen: '\" & docMapper(x) & "\' ! <<<"    ': FlashCtrl True, Me, lblVent, vbRed
            loopThroughFiles (TrimFrom("Right", CurrentDb.Name, "\") & docMapper(x) & "\")
        Next x
        lblVent.Visible = False
        btnTestLinkFil.Enabled = True
        btnSlet.Enabled = True
        ''''''''''''''''''''''''''''''''''''''''''      Word.Application.Quit <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    End Sub
    When the code run as shown - it works nicely BUT leaves an instance of Word running hidden !

    I tried to get rid of that hidden instance by the Word.Application.Quit BUT then I get the situation as described in my first posting.

    How to cure this ? (my original Q !)

  5. #5
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    377
    Googling has a few threads that say using late binding may solve this problem.

    Also see this link...https://support.microsoft.com/en-ca/...rror-message-o

  6. #6
    ksor's Avatar
    ksor is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    119
    Oh, why do I not get mail when some one ansers - sorry for the delay !

    "Late binding" of what ?

    I just want the running instance of Word "killed" when my code is finished running.

    The code I showed handlles it nicely time and again but leaves the instance of Word running.

    If I "kill" that instance manually and run my code again I get the error - and I can't see what is the difference from when I first started my code Word wasn't running then either - so why ?

  7. #7
    Gicu's Avatar
    Gicu is offline Expert
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    856
    Sorry to repeat myself, but the code you have doesn't seem to be complete, the first post has the sub named loopthroughhyperlinks and yet in the second you call a loopTroughFiles.

    Also, you need to define a variable for the Word.Application, then set it (Set oWord = GetObject(, "Word.Application") then use that instance in your code (Set doc = oWord.Documents.Open(fileName:=strFile, Visible:=False) and finally quit it:

    Set oWord=Nothing
    oWord.Quit

    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  8. #8
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    377
    This may be the relevant part of the link I suggested...
    When you write code to use a Word object, method, or property, you should always precede the call with the appropriate object variable. If you do not, Visual Basic uses a hidden global variable reference which it sets to the currently running instance. If Word is shutdown, or if the declared object variable is released, the hidden global variable will now reference an invalid (destroyed) object. When running the automation code again, calls to this hidden object variable will fail with the aforementioned error.
    And the aforementioned error is

    Error message 1Run-time error '-2147023174' (800706ba)
    Automation error

    Error message 2
    Run-time error '462': The remote server machine does not exist or is unavailable
    The above is in line with Vlad's advice.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. DLookUp command stoped working
    By WAVP375 in forum Access
    Replies: 5
    Last Post: 06-25-2019, 01:26 PM
  2. Upgrade from SQL Server 2008 to SQL Server 2014
    By RayMilhon in forum SQL Server
    Replies: 4
    Last Post: 07-12-2017, 04:54 PM
  3. Mailing works for PRD server but not for DEV server
    By violeta_barajas in forum Access
    Replies: 0
    Last Post: 11-09-2016, 12:34 PM
  4. Replies: 0
    Last Post: 12-20-2012, 01:44 PM
  5. ole server
    By sean in forum Access
    Replies: 0
    Last Post: 09-24-2009, 05:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Tech Forums: Microsoft Office Forums