Function BuildOpenString(sWizardPageName) Const vbTextCompare = 1 Const vbReplaceAll = -1 Dim sChmFilePrefix Dim nPos Dim nStart Dim nLenght Dim sPathAndFileName Dim sPath Dim sStdName Dim sStr sPathAndFileName = Window.location.pathname ' Convert %5C to real backslashes "\" sPathAndFileName = Replace(sPathAndFileName, "%5C", "\", 1, vbReplaceAll, vbTextCompare) ' Remove possible leading text from chm-file path sChmFilePrefix = "@MSITStore:" nLength = Len(sChmFilePrefix) nStart = InStr(1, sPathAndFileName, sChmFilePrefix, vbTextCompare) If nStart <> 0 Then sPathAndFileName = Mid(sPathAndFileName, (nStart + nLength)) End If ' Remove trailing file name sPath = sPathAndFileName If InStr(1, sPath, "\", vbTextCompare) Then For nPos = Len(sPath) To 1 Step -1 If Mid(sPath, nPos, 1) = "\" Then sPath = Left(sPath, nPos) Exit For End If Next End If ' Remove "/" and chm file name from topic file name sStdName = Right(sPathAndFileName, Len(sPathAndFileName) - nPos) If InStr(1, sStdName, "/", vbTextCompare) Then nLength = Len(sStdName) For nPos = nLength To 1 Step -1 If Mid(sStdName, nPos, 1) = "/" Then sStdName = Mid(sStdName, nPos + 1, nLength - nPos) Exit For End If Next End If sStr = "File:///" & sPath & sWizardPageName sStr = sStr & "?Std=" & sStdName & "&Note=none" BuildOpenString = sStr End Function Sub WriteNote() Const localizedtextWRITENOTE_FAILED = "Не удалось создать новую заметку." Const localizedtextONE_SESSION_ONLY = "Одновременно можно редактировать только одну заметку. Закончите редактирование первой заметки и повторите попытку." Const localizedtextTECHNICAL_MESSAGE_HEADING = "Далее приводится техническое описание проблемы:" Dim obj Dim bSuccess Dim bInProgress Dim sErrMsg Dim sStr Dim sMsg On Error Resume Next ' Create instance of DLL which provides a safe interface to the Company Notes server Set obj = CreateObject("CompNotesHtml.clsSafeAccess") If (Err.Number = 0) And (Not (obj Is Nothing)) Then ' Check if the Company Notes wizard is already in use bSuccess = obj.EditingSessionIsInProgress(bInProgress, sErrMsg) If bSuccess Then If Not bInProgress Then ' Create data for URL string sStr = BuildOpenString("write_company_note.htm") ' Open the Company Notes wizard Window.Open sStr, "messageWindow", "toolbar=no, width=600, height=346, scrollbars=no, resizable=no" Else sMsg = localizedtextONE_SESSION_ONLY MsgBox sMsg, 0, "Navision Attain" End If Else sMsg = localizedtextWRITENOTE_FAILED & Chr(13) & Chr(13) sMsg = sMsg & localizedtextTECHNICAL_MESSAGE_HEADING & Chr(13) sMsg = sMsg & "WriteNote() in NSHelp.vbs: Call to clsSafeAccess.EditingSessionInProgress falied. Error: " & Err.Number & " " & Err.Description & ". " & sErrMsg sMsg = sMsg & sErrMsg MsgBox sMsg, 0, "Navision Attain" End If Else sMsg = localizedtextWRITENOTE_FAILED & Chr(13) & Chr(13) sMsg = sMsg & localizedtextTECHNICAL_MESSAGE_HEADING & Chr(13) sMsg = sMsg & "WriteNote() in NSHelp.vbs: Could not create object clsSafeAccess. Error: " & Err.Number & " " & Err.Description sMsg = sMsg & sErrMsg MsgBox sMsg, 0, "Navision Attain" End If End Sub Sub EditNote() Const localizedtextWRITENOTE_FAILED = "Не удалось создать заметку" Const localizedtextONE_SESSION_ONLY = "Одновременно можно редактировать только одну заметку. Закончите редактирование первой заметки и повторите попытку." Const localizedtextTECHNICAL_MESSAGE_HEADING = "Далее приводится техническое описание проблемы:" Dim obj Dim bSuccess Dim bInProgress Dim sErrMsg Dim sStr Dim sMsg On Error Resume Next ' Create instance of DLL which provides a safe interface to the Company Notes server Set obj = CreateObject("CompNotesHtml.clsSafeAccess") If (Err.Number = 0) And (Not (obj Is Nothing)) Then ' Check if the Company Notes wizard is already in use bSuccess = obj.EditingSessionIsInProgress(bInProgress, sErrMsg) If bSuccess Then If Not bInProgress Then ' Create data for URL string sStr = BuildOpenString("edit_company_note.htm") ' Open the Company Notes wizard Window.Open sStr, "messageWindow", "toolbar=no, width=600, height=346, scrollbars=no, resizable=no" Else sMsg = localizedtextONE_SESSION_ONLY MsgBox sMsg, 0, "Navision Attain" End If Else sMsg = localizedtextWRITENOTE_FAILED & Chr(13) & Chr(13) sMsg = sMsg & localizedtextTECHNICAL_MESSAGE_HEADING & Chr(13) sMsg = sMsg & "EditNote() in NSHelp.vbs: Call to clsSafeAccess.EditingSessionInProgress failed. Error: " & Err.Number & " " & Err.Description & ". " & sErrMsg sMsg = sMsg & sErrMsg MsgBox sMsg, 0, "Navision Attain" End If Else sMsg = localizedtextWRITENOTE_FAILED & Chr(13) & Chr(13) sMsg = sMsg & localizedtextTECHNICAL_MESSAGE_HEADING & Chr(13) sMsg = sMsg & "EditNote() in NSHelp.vbs: Could not create object clsSafeAccess. Error: " & Err.Number & " " & Err.Description sMsg = sMsg & sErrMsg MsgBox sMsg, 0, "Navision Attain" End If End Sub Function CompanyNotes(sUrlOfStandardTopic) ' This function returns a string to be inserted into the body of an HTML page. ' If the Company Notes feature of Navision Attain is not activated, the string ' will be empty. If the feature is activated, the string will contain the HTML code ' needed to show company notes. Const localizedtextNOTE_CHECK_FAILED = "Во время проверки существования заметки по данной теме обнаружена ошибка." Const localizedtextNOTE_WRITELINK_FAILED = "Во время отображения ссылки для написания новой заметки обнаружена ошибка." Const localizedtextNOTE_SHOW_FAILED = "Во время отображения заметки по этой теме обнаружена ошибка." Const localizedtextCONTACT_ADMINISTRATOR = "За устранением проблемы обратитесь к системному администратору." Const localizedtextTECHNICAL_MESSAGE_HEADING = "Далее приводится техническое описание проблемы:" Dim obj Dim sStr Dim sHeading Dim sCaption Dim bSuccess Dim bInitialized Dim bNoteExists Dim sNoteFileName Dim bEditAllowed Dim sErrMsg Dim sMsg ' Create instance of DLL which provides a safe interface to the Company Notes server On Error Resume Next Set obj = CreateObject("CompNotesHtml.clsSafeAccess") If Err.Number = 0 Then ' Check if Company Notes are initialized for use bSuccess = obj.ClassIsInitialized(bInitialized, sErrMsg) If (Err.Number = 0) And bSuccess Then If bInitialized Then bSuccess = obj.NoteAvailable(sUrlOfStandardTopic, bNoteExists, sNoteFileName, bEditAllowed, sErrMsg) If (Err.Number = 0) And bSuccess Then If bNoteExists Then ' A Company Note exists bSuccess = obj.TopicGetNoteHeading(sHeading, sErrMsg) If (Err.Number = 0) And bSuccess Then ' Create a table with one cell to contain the inserted elements CompanyNotes = "
" ' Contents of table begins here CompanyNotes = CompanyNotes & "

" & sHeading & "


" ' Insert company note in iframe CompanyNotes = CompanyNotes & "" ' Insert link to editing the company note If bEditAllowed Then bSuccess = obj.TopicGetEditCaption(sCaption, sErrMsg) If (Err.Number = 0) And bSuccess Then sStr = "" sStr = "" & sCaption & "" CompanyNotes = CompanyNotes & sStr Else ' TopicGetEditCaption failed sMsg = localizedtextNOTE_SHOW_FAILED & Chr(13) & Chr(13) sMsg = sMsg & localizedtextCONTACT_ADMINISTRATOR & Chr(13) & Chr(13) sMsg = sMsg & localizedtextTECHNICAL_MESSAGE_HEADING & Chr(13) sMsg = sMsg & "CompanyNotes() in NSHelp.vbs: Failed to get Editing Link Text. Error: " & Err.Number & " " & Err.Description & ". " & sErrMsg MsgBox sMsg, 0, "Navision Attain" End If Else ' User is not allowed to edit the note End If ' Contents of table ends here sStr = "
" CompanyNotes = CompanyNotes & sStr Else ' TopicGetNoteHeading failed sMsg = localizedtextNOTE_SHOW_FAILED & Chr(13) & Chr(13) sMsg = sMsg & localizedtextCONTACT_ADMINISTRATOR & Chr(13) & Chr(13) sMsg = sMsg & localizedtextTECHNICAL_MESSAGE_HEADING & Chr(13) sMsg = sMsg & "CompanyNotes() in NSHelp.vbs: A note exists for this topic. Failed to get Company Note Heading. Error: " & Err.Number & " " & Err.Description & ". " & sErrMsg MsgBox sMsg, 0, "Navision Attain" End If Else ' No Company Note exists If bEditAllowed Then ' Insert link to writing a company note. Right-justified in yellow background cell. bSuccess = obj.TopicGetWriteCaption(sCaption, sErrMsg) If (Err.Number = 0) And bSuccess Then ' Create a table with one cell to contain the inserted elements CompanyNotes = "
" ' Contents of table begins here sStr = "" sStr = "" & sCaption & "" CompanyNotes = CompanyNotes & sStr ' Contents of table ends here sStr = "
" CompanyNotes = CompanyNotes & sStr Else ' TopicGetWriteCaption failed sMsg = localizedtextNOTE_WRITELINK_FAILED & Chr(13) & Chr(13) sMsg = sMsg & localizedtextCONTACT_ADMINISTRATOR & Chr(13) & Chr(13) sMsg = sMsg & localizedtextTECHNICAL_MESSAGE_HEADING & Chr(13) sMsg = sMsg & "CompanyNotes() in NSHelp.vbs: No note exists for this topic. Failed to get Writing Link Text. Error: " & Err.Number & " " & Err.Description & ". " & sErrMsg MsgBox sMsg, 0, "Navision Attain" End If Else ' User cannot write notes (no write-access to shared folder) End If End If Else ' NoteAvailable failed sMsg = localizedtextNOTE_CHECK_FAILED & Chr(13) & Chr(13) sMsg = sMsg & localizedtextTECHNICAL_MESSAGE_HEADING & Chr(13) sMsg = sMsg & "CompanyNotes() in NSHelp.vbs: Failed calling NoteAvailable(). Error: " & Err.Number & " " & Err.Description & ". " & sErrMsg MsgBox sMsg, 0, "Navision Attain" End If Else ' CompNotesHtml clsSafeAccess returned False on IsInitialized(). ' Maybe no Navision Attain is running - and thus no CompNotes.exe. ' Maybe Navision Attain is running but Company Notes has not been activated, so CompNotes.exe was not initialized. ' Don't report this because help project must be able to run without support for Company Notes. End If Else ' ClassIsInitialized failed sMsg = localizedtextNOTE_CHECK_FAILED & Chr(13) & Chr(13) sMsg = sMsg & localizedtextTECHNICAL_MESSAGE_HEADING & Chr(13) sMsg = sMsg & "CompanyNotes() in NSHelp.vbs: Failed calling CompNotesHtml clsSafeAccess ClassIsInitialized(). Error: " & Err.Number & " " & Err.Description & ". " & sErrMsg MsgBox sMsg, 0, "Navision Attain" End If Else ' Failed instantiating CompNotesHtml clsSafeAccess. ' Don't report this because help project must be able to run without support for Company Notes. End If End Function