Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.

Answered Word-VBA-Error 5096: "PHABETI"

  • Thursday, May 19, 2011 11:12 AM
     
     

    hi all ..

    I have a Word VBA makro that opens files, does some replacements and saves the files again.
    The makro normaly works fine with all Windows- and Word-Versions (2000-2010).
    Now I have a customer who has about 40 files, and when the makro runs, he gets the error "5096: PHABETI (filename)".
    The makro continues with the other files without problems.
    It is allways another file, that generates the error, and actually it's only 1 file each time.
    When the makro runs 5 times, 4 times the error occurs, 1 time all is ok.
    Next time maybe 6 trys are necesarry to get an ok for all files.

    The customer runs the makro on Windows 7, Word-Version is 2007.

    I have found some informations, that this problems sometimes occurs when saving files (this was allways the problem, not vba, sometimes the problem came with Word 2010), but I have found no answers.

    One year ago, a had the same problem with another customer with Windows 7 and Word 2007 too.
    The files are located on a network-drive (in both cases).

    For me as a first step it wood be very helpfull to know, what this error means (PHABETI is not really clear).

    Thanks for your answers.

     

All Replies

  • Thursday, May 19, 2011 11:54 AM
     
     
    I have never heard of this but a quick web search (returning only foreign language hits) suggests that anti-virus software could be causing this.
     

    Enjoy,
    Tony
    www.WordArticles.com
  • Friday, May 20, 2011 4:29 AM
    Moderator
     
     

    Hi,

     

    Would you like to post your code and tell us where the bug happens? I’ll try to reproduce the issue as soon as I get sufficient information :-)

     

    I look forward to hearing of you soon.


    Best Regards, Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Wednesday, May 25, 2011 7:10 AM
    Moderator
     
     

    Hi,

    How about the issue now on your side? Have you solved it?

     

    I look forward to hearing of you.


    Best Regards, Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Wednesday, May 25, 2011 11:52 PM
     
      Has Code

    Hi Calvin_Gao,

    sorry that you had to wait for my answer, but I was waiting for further information of my customer.

    I can't send you the exact code, that produces the error, because it's part of a complex set of functions.
    I found only a few more Phabeti-Errors on a web search, and one was from netherlands, one from italy and three or four from germany. My error is from germany too. In all the notes I found, the problem had to do with saving a file. This is the problem of my customer too.
    I my code I save a text-file, that I have opened with Word and I save it again with a certain Encoding, for example Ansi-88591 or UTF-8.
    For this I use the following VBA-Code:

    'Saves as UTF-8 Public Function DocumentSaveAsUTF8Text(strFileName As String, doc As Word.Document) As Boolean
    Call DocumentSaveAs(doc, strFileName, msoEncodingUTF8)
    End Function
    Public Function DocumentSaveAs(doc As Word.Document, strFileName As String, lngEncoding As Long) As Boolean
    #If vw2000 Then
    doc.SaveEncoding = lngEncoding
    doc.SaveAs FileName:=strFileName, FileFormat:=wdFormatEncodedText, AddToRecentFiles:=False
    #Else
    doc.SaveAs FileName:=strFileName, FileFormat:=wdFormatEncodedText, AddToRecentFiles:=False, Encoding:=lngEncoding
    #End If
    End Function

    I can give you some extracts of the customers process-protocol (german date-format, dd.mm.yyyy):

    12.05.2011 09:04:07 Starting Export.
    ...
    WordVersion: 12.0.6545
    WordLanguageUserInterface: 1031
    OfficeLanguage: 1031
    OperatingSystem: Windows NT 6.1
    ---------------------------------------------
    ...
    ...
    ... here for example 40 files ok, then:
    ...
    Runtime-Error: 12.05.2011 09:06:38
    LibExportMain.ExportIntranet()
    5096: PHABETI
     (header.js)
    ...
    ...
    12.05.2011 09:08:18 End of Export with Error(s).
    ================================
    



    Next try:
    ...
    Runtime-Error: 12.05.2011 09:36:41
    LibExportTools.ReplaceTextAUC()
    5096: PHABETI
     (web_style_OP.css)
    ...
    ...

    A lot of customers use our code, with Word-Versions from 2000 - 2010 and with Windows-Versions from XP to Windows7 SP1, most of them with german Windows and german Word. Normaly there are no (phabeti-)problems.
    We cannot reproduce the error of our customer.

    So I hope you can give us a tip for our further search.

    And I think, as I said in my question, that maybe it would be helpfull to know, what this error means.

    Thanks for your answers

     

  • Friday, May 27, 2011 8:13 AM
    Moderator
     
     Answered

    Hi,

     

    When you develop target from Word 2007 to 2010, you need some updates your code.

    I guess that the issue is cause by the changing of SaveAs methond name. Please see the reference below:

    SaveAs Method (2003)

    Document.SaveAs Method (2007)

    SaveAs2 Method (Word) (2010)

     

    You can try to change some related codes to fit the new method.

     

    I hope this helps.


    Best Regards, Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Wednesday, June 01, 2011 3:31 AM
    Moderator
     
     

    Hi Uvju,

    How about the issue on your side now? Have you solved it?

    I look forward to hearing of you.


    Best Regards, Calvin Gao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Friday, July 15, 2011 10:13 PM
     
     

    Get this error too - or at least something very like it.

    I have an Excel 2007 VBA macro which produces a MS WORD 2007 document, running on Win7.  Worked like a dream, thought I'd get smart and started to create and customise my own text styles for the output file.  Program stopped working and threw a 5096 error when attempting to do a SAVE AS.

    Backed out all of my code changes to no avail, it still ran into a brick wall.  Shut down Word and Excel and opened up the Excel spreadsheet again and reran the same code.  It worked fine.  Put in my styles code again and it still works fine.

    I cannot be precise, but this has all of the hall marks of something screwed up 'over there' manifesting in something else 'over here' - that is the problem is not with the SAVEAS action, only that is th epoint that it becomes visible.  Is it possible that your code is masking / not handelling errors elsewhere?

    Note I have also seen my code fail (document server not there or the like) on alternate runs (whilst applying tabs to a style) when executing on Win7, but (the very same file) running like a dream on Vista.

    I smell rats in the operational environment / missed error states here.

    HTH at least a little!

  • Wednesday, October 26, 2011 6:09 PM
     
     Proposed

    I have the PHABETI issue too, but I have it in Access, using a Wordfile to write to.

    I never had this problem until a year back some updates to the network where done.

    Since non of the network people know anything about Access, they cannot solve my problem.

    I enter the code I use:

    Option Compare Database
    Option Explicit

    '*********************************************************************************
    '**********************    ALLE CONTRACTEN   *************************************
    '*********************************************************************************
    Function Contract_ALL(lngPersonID As String)
    On Error GoTo Contract_ALL_Err

    Dim gconTemplate2 As Variant
    Dim gconTemplate1 As Variant

    gconTemplate1 = DLookup("[DocumentOphalen]", "TblDOCUMENTENLINKS", "[ConstantID] = 1")
    gconTemplate2 = DLookup("[DocumentWegschrijven]", "TblDOCUMENTENLINKS", "[ConstantID] = 1")


    If gconTemplate1 = Null Or gconTemplate2 = Null Then
        MsgBox "Opzoekwaarde kan niet worden gevonden"
       
        Exit Function
    Else
    End If
    'DoCmd.RunCommand acCmdSaveRecord

    'Dim db As Database
    'Dim rec As Recordset


    'Set db = CurrentDb()
    'Set rec = db.OpenRecordset("QryContract3")
    'DoCmd.SetWarnings False
    'Make Sure Table for Labels is empty
    'DoCmd.OpenQuery "qryLabelsVerwijderen", acViewNormal
    'DoCmd.SetWarnings True
    'Go until last record

        'Set Amount of labels
       
            
             'Write labelinformation into Table
            

    Dim dbC         As Database             ' current database
    Dim qryContact  As QueryDef             ' querydef of contact
    Dim recContact  As Recordset            ' recordset of contact details
    Dim objWord     As Word.Application     ' word object
    Dim objDoc      As Object               ' document object
    Dim Aantal As Integer
    Dim i As Integer


    Set objWord = Nothing

    Set dbC = CurrentDb()
    Set qryContact = dbC.QueryDefs("qry AlleContracten")
    qryContact.Parameters("pid") = lngPersonID

    Set recContact = qryContact.OpenRecordset()
    Do Until recContact.EOF
     Aantal = 1
         For i = 1 To Aantal
    'If recContact.EOF Then
      '  MsgBox "The person with an ID of " & lngPersonID & " could not be found.", _
         '  vbCritical, "Contact Not Found"
      '  Exit Function
    'End If

    ' create word and a letter based on the template
    Set objWord = New Word.Application
    objWord.Visible = True
    Set objDoc = objWord.Documents.Add(gconTemplate1)
    ' fill in the details(LowerCase)

    InsertTextAtBookmark objWord, objDoc, "Achternaam", recContact(UCase("Naam1"))
    InsertTextAtBookmark objWord, objDoc, "Adres", recContact("Adres")
    InsertTextAtBookmark objWord, objDoc, "Woonplaats", recContact("Woonplaats")
    InsertTextAtBookmark objWord, objDoc, "Postcode", recContact("PostCode")
    InsertTextAtBookmark objWord, objDoc, "Periodevan", Format(recContact("Periodevan"), "dd mmmm yyyy")
    InsertTextAtBookmark objWord, objDoc, "Periodetot", Format(recContact("Periodetot"), "dd mmmm yyyy")
    InsertTextAtBookmark objWord, objDoc, "Aanspreektitel", recContact("Instrument")
    InsertTextAtBookmark objWord, objDoc, "Functie", recContact("Functie")

    Select Case recContact("hoedanigheid")
    Case "extra"
    InsertTextAtBookmark objWord, objDoc, "Varia", "aanvullend musicus"
    Case Else
    InsertTextAtBookmark objWord, objDoc, "Varia", "vervangend musicus"
    End Select


    InsertTextAtBookmark objWord, objDoc, "Productie", recContact("Productie")
    InsertTextAtBookmark objWord, objDoc, "Componist", recContact("Componist")
    InsertTextAtBookmark objWord, objDoc, "Periodevan2", Format(recContact("Periodevan"), "dd mmmm yyyy")

    Dim Date1 As Date
    Dim Date2 As Date
    Date1 = recContact("Periodetot")
    Date2 = recContact("Datumgenerale")
    'MsgBox "Laatste vrst: " & Date1 & "----" & "Generale: " & Date2

    Select Case Date1
           Case Is > Date2
                'Eval ("MsgBox('Groter." & vbCrLf & "@Even testen.@@')")
                InsertTextAtBookmark objWord, objDoc, "Datumgenerale", Format(recContact("Datumgenerale"), "dd mmmm yyyy") & " de dag van de" & Chr(9) & "generale repetitie."
                InsertTextAtBookmark objWord, objDoc, "VoorstellingenAntw", recContact("VoorstellingenA")
                InsertTextAtBookmark objWord, objDoc, "LocatietextAntwerpen", "in de Vlaamse Opera te Antwerpen"
                InsertTextAtBookmark objWord, objDoc, "VoorstellingenGent", recContact("VoorstellingenG")
                InsertTextAtBookmark objWord, objDoc, "LocatietextGent", "in de Vlaamse Opera te Gent"
               
              If IsNull(recContact("VoorstellingenAndere")) Then
                    InsertTextAtBookmark objWord, objDoc, "VoorstellingenAndere", ""
                   Else
                  InsertTextAtBookmark objWord, objDoc, "VoorstellingenAndere", "- " & recContact("voorstellingenandere") & Chr(13)
              End If
             
    If IsNull(recContact("Datumtransfer")) Then
        InsertTextAtBookmark objWord, objDoc, "locatietextAndere", Chr(13) & Chr(9) & "Tenzij anders vermeld beginnen de voorstellingen om 20 uur." & Chr(13)
        Else
                InsertTextAtBookmark objWord, objDoc, "locatietextAndere", Chr(13) & Chr(9) & "Tenzij anders vermeld beginnen de voorstellingen om 20 uur." & Chr(13) & _
                "Tussen de laatste voorstelling in de ene stad en de tweede première in de andere stad vindt een transferrepetitie plaats." & _
                "Voor deze productie is dat op " & Format(recContact("Datumtransfer"), "dd mmmm yyyy") & " om " & Format(recContact("Uurtransfer"), "hh:mm") & " uur te " & recContact("Locatietransfer") & "." & Chr(13)
                  InsertTextAtBookmark objWord, objDoc, "locatietextAndere", "op locatie (Zie planning)" & Chr(13) & Chr(13)
    End If

         Case Is < Date2
              'Eval ("MsgBox('Kleiner." & vbCrLf & "@Even testen.@@', 16, 'Datum evaluatie')")
             InsertTextAtBookmark objWord, objDoc, "Datumgenerale", Format(recContact("Periodetot"), "dd mmmm yyyy") & "."
              InsertTextAtBookmark objWord, objDoc, "VoorstellingenAntw", "De Artiest neemt geen deel aan de voorstellingen"
        Case Else
             'Eval ("MsgBox('Gelijk." & vbCrLf & "@Even testen.@@', 16, 'Datum evaluatie')")
            InsertTextAtBookmark objWord, objDoc, "Datumgenerale", Format(recContact("Datumgenerale"), "dd mmmm yyyy") & " de dag van de generale repetitie."
            InsertTextAtBookmark objWord, objDoc, "VoorstellingenAntw", "De Artiest neemt geen deel aan de voorstellingen"
    End Select


    InsertTextAtBookmark objWord, objDoc, "Repetitie", recContact("RepEuro")
    InsertTextAtBookmark objWord, objDoc, "Repetitie2", recContact("Rep2Euro")
    InsertTextAtBookmark objWord, objDoc, "Concert", recContact("ConcertEuro")

    If IsNull(recContact("Iban")) Then
    InsertTextAtBookmark objWord, objDoc, "Iban", "BE.. .... .... ...."
    Else
    InsertTextAtBookmark objWord, objDoc, "Iban", recContact("Iban")
    End If

    i = DateDiff("d", Date, recContact("periodevan"))

    If i < 2 Then
    InsertTextAtBookmark objWord, objDoc, "Contractdatum", Format(recContact("Periodevan") - 2, "dd mmmm yyyy")
    Else
    InsertTextAtBookmark objWord, objDoc, "Contractdatum", Format(recContact("Periodevan") - i, "dd mmmm yyyy")
    End If

    InsertTextAtBookmark objWord, objDoc, "naam3", recContact("Naam1")
    'InsertTextAtBookmark objWord, objDoc, "naam2", recContact("Achternaam")

    ' close up

    'Dim filetx As String
    'filetx = gconTemplate2 & "/" & recContact("Productie") & "_" & recContact("Naam1") & "_" & recContact("Reden") & "_" & recContact("Naam2")
    'If My.Computer.FileSystem.FileExists("filetx") Then
      '  MsgBox ("File found.")
    'Else
      '  MsgBox ("File not found.")
    'End If

     

    objDoc.SaveAs gconTemplate2 & "/" & recContact("Productie") & "_" & recContact("Naam1") & "_" & recContact("Reden") & "_" & recContact("Naam2")


    'If MsgBox("Contract is gesaved in CONTRACTEN, wenst U Word af te sluiten?", vbOKCancel, "Word Afsluiten?") = vbOK Then
    'objDoc.Close
    'objWord.Quit
    'recContact.Close
    'Set objDoc = Nothing
    'Set objWord = Nothing
    'Else
    'Resume Next
    'End If

    Set objWord = Nothing


    Next i

    'Move to next record
    recContact.MoveNext

    Loop

    'If finished open Report
    'DoCmd.OpenReport "rptLabels", acViewPreview

     

    Contract_ALL_Exit:
        Exit Function

    Contract_ALL_Err:
       Call foutopsporing
        Resume Contract_ALL_Exit

    End Function

    Sub InsertTextAtBookmark(objW As Object, objD As Object, strBkmk As String, _
        varText As Variant)

        ' select the required bookmark, and set the selection text
       objD.Bookmarks(strBkmk).Range.Text = Nz(varText, "")

    End Sub

  • Wednesday, November 23, 2011 8:01 PM
     
     

    i = DateDiff("d", Date, recContact("periodevan")) If i < 2 Then InsertTextAtBookmark objWord, objDoc, "Contractdatum", Format(recContact("Periodevan") - 2, "dd mmmm yyyy") Else InsertTextAtBookmark objWord, objDoc, "Contractdatum", Format(recContact("Periodevan") - i, "dd mmmm yyyy") End If

    his was the problem, I used the "i" for 2 different things, which of course cannot, so I found my own fault.

     

  • Wednesday, August 08, 2012 7:37 PM
     
     

    Hi Uvju,

    You have probably resolved this issue.  I had the same problem.  The statement "Activedocument.save" was attempting to save the document directly to the user's folder in windows 7.  The work around was to change the default document path to the network path; save the document; and reset the default document path.

  • Tuesday, March 26, 2013 2:40 PM
     
     

    Hi,

    I found this post because i had the same error and it was generated on saving a small document with the statement "saveas".

    Since i haven't had this error before i checked what recently changed. Here is what i found:

    I was working in a document with another (new) font and fontsize then the default font and fontsize in Word. My addin selected a small portion of a text in this document, creates a new document and past the text in this new document.  On saving this new document the error occurred.

    So i changed the standard word template with the new font and fontsize and repeated the same steps. The error was gone.

    I hope this helps someone.

    Regards,

    Jacob Iedema