My Firm is in the process of upgrading from Hummingbrid 5.1 to Filesite 8.2.We're going to deploy the matter centric approach with enhanced dialogs, and I've been trying to customize the custft8xEAI-e.dot macro available form interwoven to:1. Insert the document # after the last paragraph instead of the footer.2. Do this by a keystroke or drop down menu, rather than automagically.3. Secondarily, also have the following menu options: a. Put the Doc # in the footer b. Remove the Doc # from either the footer or after the last paragraph.I’ve managed to change the inserting the Doc # after the last paragraph with the following code placed in the end of the sinkobject in the Word VBA code(an edit the FootActiveDocument):Public Sub FootActiveDocument(objDocumentToFoot As IManage.IManDocument) Dim objFooter As FooterObject Dim strDocVerDivider As String Dim strFieldDivider As String Dim strText As String On Error Resume Next ' Create an instance of the FooterObject object Set objFooter = New FooterObject ' Select document profile field info to foot AddFooterProfileInfo objFooter ' Get field separators AddFieldDividers strFieldDivider, strDocVerDivider ' Build footer text string and hold it in strText variable strText = objFooter.FooterText(objDocumentToFoot, strFieldDivider, strDocVerDivider) ' Insert footer text ' Altered to insert 3 hard returns and Document # after last paragraph ActiveDocument.Content.InsertParagraphAfter ActiveDocument.Content.InsertParagraphAfter ActiveDocument.Content.InsertParagraphAfter ActiveDocument.Content.InsertAfter (strText) ' Free pointer before exiting Set objFooter = NothingEnd SubThe problem with this code is it runs every time Word opens a document, so it adds the doc # at the end every time you open the document and you get a long list of document #'s appended to the end of every docuemnt every time it is opened.First and foremost I’d like to prevent the # from being added automatically, but have it added by keystroke or menu shortcut.Any help is great appreciated!Thanks!A. NahrSystems AnalystMeagher & Geer PLLPMinneapolis, MN
OK, I commented out the DocumentOpen as suggested, and now the macro does not work at all. Here is the code for the SinkObject:' CUSTFT80E - WORKSITE VERSION 8.0' SinkObject'--------1---------2---------3---------4---------5---------6---------7---------8Option Explicit' NOTE: To set up a sink for the application's events (DocumentBeforePrint,' DocumentBeforeSave, etc.), uncomment the lines between the lines' SINK APPLICATION EVENTS and END SINK APPLICATION EVENTS.' An example of a sinked application event is between the lines' SINK APPLICATION EVENT EXAMPLE and END SINK APPLICATION EVENT EXAMPLE.Private WithEvents objExtensibilitySink As iManO2K.iManageExtensibilityPrivate WithEvents objEditProfileCmdSink As IMANEXTLib.EditProfileCmdPrivate WithEvents objIManFileSaveCmdSink As IMANEXT2Lib.IManFileSaveCmdPrivate WithEvents objNewVersionCmdSink As IMANEXTLib.NewVersionCmd' SINK APPLICATION EVENTSPrivate WithEvents objApplication As Word.Application' END SINK APPLICATION EVENTS' Variables for the Application_Quit event handler.Private objDocPrintFromClient As IManage.IManDocumentPrivate strPrintFile As StringPublic Sub SinkIManageExtensibility( _ objExtensibility As iManO2K.iManageExtensibility) On Error Resume Next Set objExtensibilitySink = objExtensibility ' SINK APPLICATION EVENTS Set objApplication = Word.Application ' END SINK APPLICATION EVENTSEnd Sub'Private Sub objApplication_DocumentOpen(ByVal Doc As Document)' Dim objDocument As IManage.IManDocument' Set objDocument = objExtensibilitySink.GetDocumentFromPath(Doc.FullName)' If Not objDocument Is Nothing Then' FootActiveDocument objDocument' Set objDocument = Nothing' End If'End Sub' NOTE: This event is fired to check whether or not objDocPrintFromClient is null.' If not, it will locate printed document from ..\Netright\Print directory' and check it into WorkSite. This will allow WorkSite to store the footed' document that was opened from within the Desktop client for printing.' Uncomment the lines between WORK-AROUND IMPLEMENTATION' and ENDS WORK-AROUND IMPLEMENTATION in the event' to include this implementation.'Private Sub objApplication_Quit() ' WORK-AROUND IMPLEMENTATION' On Error Resume Next' If Not objDocPrintFromClient Is Nothing Then' ' A footed version of the document is in the ..\Netright\Print directory' Dim strTemp As String' Dim iErrs' Dim FSO' Const fldr = 2'' ' Build checkout path' Set FSO = CreateObject("Scripting.FileSystemObject")' strTemp = FSO.BuildPath(FSO.GetSpecialFolder(fldr), FSO.GetTempName)'' If objDocPrintFromClient.CheckedOut = False Then' ' Check-out to the temp file' objDocPrintFromClient.CheckOut strTemp, nrReplaceExistingFile, Date, ""' ' Check-in footed doc; strPrintFile holds the footed document filepath' objDocPrintFromClient.CheckIn strPrintFile, nrReplaceOriginal, nrDontKeepCheckedOut, iErrs' End If'' ' Done with temp file, destroy it' Kill strTemp'' ' Free pointers before exiting' Set FSO = Nothing' Set objDocPrintFromClient = Nothing' End If ' ENDS WORK-AROUND IMPLEMENTATIONEnd SubPrivate Sub objExtensibilitySink_OnCreateNewVersion( _ ByVal objNewVersionCmd As Object) Dim objDocument As IManage.IManDocument Set objDocument = _ objExtensibilitySink.GetDocumentFromPath(Word.ActiveDocument.FullName) If Not objDocument Is Nothing Then objDocument.Refresh End If Set objNewVersionCmdSink = objNewVersionCmd Set objDocument = NothingEnd SubPrivate Sub objExtensibilitySink_BeforePrintDialog() Dim objDocument As IManage.IManDocument Set objDocument = objExtensibilitySink.GetDocumentFromPath(Word.ActiveDocument.FullName) If Not objDocument Is Nothing Then FootActiveDocument objDocument Set objDocument = Nothing End IfEnd Sub'NOTE: Work-around for footing a WorkSite document printed from WorkSite Clients' (Print command executed from within WorkSite Desktop Client application).' To include this work-around, uncomment the lines between WORK-AROUND IMPLEMENTATION' and ENDS WORK-AROUND IMPLEMENTATION in the event.'' This event handler is an example of how to foot a WorkSite document before printing.' This event is only fired when documents in WorkSite are printed.'Private Sub objExtensibilitySink_DocumentBeforePrint(ByVal Doc As Object, IgnoreIManagePrint As Boolean, Cancel As Boolean) On Error Resume Next Dim objDocument As IManage.IManDocument Dim objDMS As IManage.NRTDMS Set objDocument = objExtensibilitySink.GetDocumentFromPath(Doc.FullName) If Not objDocument Is Nothing Then FootActiveDocument objDocument ' Free pointer before exiting Set objDocument = Nothing Exit Sub End If ' WORK-AROUND IMPLEMENTATION' If objDocument Is Nothing Then' Dim HasDocBySid As Boolean' Dim strMoniker As String' Dim strFile As String'' HasDocBySid = False ' Initialize value to False' ' Try getting the document by retrieving its moniker (DocID) from the associated .prf file' Set objDMS = objExtensibilitySink.Context("NRTDMS")' ' Hold ActiveDocument filepath in strPrintFile' strPrintFile = Doc.FullName' ' Construct PRF filename' strFile = Mid(strPrintFile, 1, Len(strPrintFile) - 3) ' Truncate last 3 chars, "doc"' strFile = strFile + "PRF" ' Concatenate "PRF" extenstion to end of string' ' Get moniker from .prf file, trim any leading and trailing spaces' strMoniker = Trim(System.PrivateProfileString(strFile, "DOCPRF", "DOCID"))' If Not IsEmpty(strMoniker) Then' Set objDocument = objDMS.GetObjectBySID(strMoniker)' HasDocBySid = True' End If' End If' ' Check whether it's from .prf file' If (Not objDocument Is Nothing) And (HasDocBySid = True) Then' FootActiveDocument objDocument' ' Save footed doc' Doc.Save' ' Put document in objDocPrintFromClient pointer' Set objDocPrintFromClient = objDocument' ' Free pointers before exiting' Set objDocument = Nothing' Set objDMS = Nothing' End If ' ENDS WORK-AROUND IMPLEMENTATIONEnd SubPrivate Sub objExtensibilitySink_OnEditProfile( _ ByVal objEditProfileCmd As Object) Set objEditProfileCmdSink = objEditProfileCmdEnd SubPrivate Sub objExtensibilitySink_OnIManFileSave(ByVal objIManFileSaveCmd As Object) Set objIManFileSaveCmdSink = objIManFileSaveCmdEnd SubPrivate Sub objIManFileSaveCmdSink_PostOnOK(ByVal pMyInterface As Object) Dim objDocument As IManage.IManDocument Set objDocument = objIManFileSaveCmdSink.Context("ImportedDocument") FootActiveDocument objDocumentEnd SubPrivate Sub objNewVersionCmdSink_PostOnOK(ByVal pMyInterface As Object) On Error Resume Next Dim objDocument As IManage.IManDocument Set objDocument = _ objNewVersionCmdSink.Context("IManExt.NewVersionCmd.Document") FootActiveDocument objDocument Set objDocument = NothingEnd SubPrivate Sub objEditProfileCmdSink_PostOnOK(ByVal pMyInterface As Object) On Error Resume Next Dim objDocument As IManage.IManDocument Dim varSelectedIManDocuments As Variant varSelectedIManDocuments = _ objEditProfileCmdSink.Context("SelectedNRTDocuments") Set objDocument = varSelectedIManDocuments(0) FootActiveDocument objDocument Set objDocument = NothingEnd Sub' Below is a sample event handler which foots the document before every save.' The portions above which set up the sink to the application's events must be' uncommented for this event handler to be called.' SINK APPLICATION EVENT EXAMPLE'Private Sub objApplication_DocumentBeforeSave(ByVal Doc As Document, _' SaveAsUI As Boolean, Cancel As Boolean)'' Dim objDocument As IManage.IManDocument' ' a document object as represented by WorkSite'' ' The Doc argument is the document being saved.'' ' Convert the Word document object to a WorkSite document using the path,' ' stored in the FullName property of the Word document object.' Set objDocument = objExtensibilitySink.GetDocumentFromPath(Doc.FullName)'' ' GetDocumentFromPath will return Nothing if the document is not a WorkSite' ' document. Foot the document only if it is a WorkSite document.' If Not objDocument Is Nothing Then' FootActiveDocument objDocument' End If' Set objDocument = Nothing'End Sub' END SINK APPLICATION EVENT EXAMPLEPrivate Sub FootActiveDocument(objDocumentToFoot As IManage.IManDocument) Dim objFooter As FooterObject Dim strDocVerDivider As String Dim strFieldDivider As String Dim strText As String On Error Resume Next ' Create an instance of the FooterObject object Set objFooter = New FooterObject ' Select document profile field info to foot AddFooterProfileInfo objFooter ' Get field separators AddFieldDividers strFieldDivider, strDocVerDivider ' Build footer text string and hold it in strText variable strText = objFooter.FooterText(objDocumentToFoot, strFieldDivider, strDocVerDivider) ' Insert footer text ActiveDocument.Content.InsertParagraphAfter ActiveDocument.Content.InsertParagraphAfter ActiveDocument.Content.InsertParagraphAfter ActiveDocument.Content.InsertAfter (strText) ' Free pointer before exiting Set objFooter = NothingEnd SubHere is the code for teh NRTAutoMacros, which obviously fired off whenever a document is opened:' CUSTFT80E - WORKSITE VERSION 8.0'NRTAutoMacros'--------1---------2---------3---------4---------5---------6---------7---------8Private Const COMMAND_BAR_NAME_STANDARD As String = "Standard" ' the name of the command bar under which the print out button residesPrivate Const MENU_ID_PRINT As Integer = 4 ' the menu ID for the print buttonPublic Const MENU_ID_PRINT_OUT As Integer = 2521 ' the menu ID for the print out buttonPrivate Const POPUP_NAME_FILE As String = "FILE" ' the name of the popup under which the print button residesPrivate objSinkObject As SinkObject ' used to set up sinks to the WorkSite Office 2000 extensibility objectPrivate objPrintBtn As Office.CommandBarButton ' the print buttonPublic Sub AutoExec() Dim objIManageExtensibility As iManO2K.iManageExtensibility ' An object used for extending the functionality of WorkSite Office 2000 ' integration. ' Get the WorkSite O2K extensibility object. Set objIManageExtensibility = _ Application.COMAddIns("iManO2K.AddinForWord2000").Object ' Set up a sink to the extensibility object. Set objSinkObject = New SinkObject objSinkObject.SinkIManageExtensibility objIManageExtensibilityEnd SubI tried firing this off manually, but it also did not work. Somehow I need the FootActiveDocument function to run on keystroke or menu click, and it's just not working. I must be missing something...I don't know much about Word VBA coding. I've been trying to google terms like 'sink object' etc, but have come up dry.Thanks agian for all your helpA. Nahr
I would like the FootActiveDocument event not to be fired off automatically, but rather by a keystroke and/or menu option.
I apologize if I did not make myself clear:By 'menu option' I mean a menu with various doc number insertion options (see attached image) as well as a keystroke for each insertion option (such as, for example, Alt+g, d etc...).Thanks for your prompt repliesA Nahr
Yes, they are dummies at this point, since I can't get any of the macros to fire off manually.
Ah, this is where I need to go.Can you give me some sample code of how to create my own instance of the iManO2K.iManageExtensiblity object? Would this all be part of the custft8xEAI-e.dot macro? Would I keep the SinkObject? or the NRTAutoMacros?Which modules should I keep? I am insterested in keeping a specific format for the document number, so keeping the FooterObject and ModFootDocument modules to build the footer would be necessary, I assume?Thanks again for helping out!!A Nahr
The code to create an instance of the iManageExtensibility object is in the NRTAutoMacros base module. It sets up a sink to the SinkObject class by passing the handle to the iManageExtensibility Object to it. The SinkObject class is just a class that has the code to catch the events of the iManageExtesibility Object as well as other command classes that are passed along by the events of the iManageExtensiblity Object.Which modules you should keep depend on which ones are useful to you in your implementation objective.
We'd like to be able to:A) insert the document number at the end of the document by a keystroke and/or drop down menu Insert the document number into the footer using a different keystroke and/or drop down menu.C) Have an option to remove these if necessary.
'Referenced IManO2k.dll, IManage.dll, and IManExt.dll'~ Code example to check connection, get the document, and get the document number.Dim objIManageExtensibility As iManO2K.iManageExtensibility' An object used for extending the functionality of WorkSite Office 2000' integration.' Get the WorkSite O2K extensibility object.Set objIManageExtensibility = _Application.COMAddIns("iManO2K.AddinForWord2000").Object'Check connectionIf objIManageExtensibility.CurrentMode = nrConnectedMode ThenDim objDocument As IManage.IManDocument'Get documentSet objDocument = objExtensibilitySink.GetDocumentFromPath(Word.Acti veDocument.FullName)If Not objDocument Is Nothing Then'Display doc number to demonstrate how to get document profile infoMsgBox objDocument.GetAttributeByID(imProfileDocNum) & "_" & objDocument.GetAttributeByID(imProfileVersion)Set objDocument = NothingEnd IfEnd If
There are two ways to add a custom menu to Office app: one is through macro, where you would bind the macro to a button. Second is through an Office COM Add-In, where you would add your own command bar control.You may use a macro to hijack the specific keyboard key you have in mind. All of which is done through Word Object Model. (If you're not familiar with these approaches, please research on it through Google or MSDN library).Once you have your WOM code base for adding a menu item and keyboard key hijack established, you would in that code reference the IManO2K.dll to get a handle to the IManageExtensiblity Object. You may then use the IManageExtensibility Object to check WorkSite connection, then check for the presence of a WorkSite document. If the document is from WorkSite, you can then get the document property info off of the document object to insert to anywhere you want in the Office document.This is the WorkSite API's that would be invovled: 'Referenced IManO2k.dll, IManage.dll, and IManExt.dll'~ Code example to check connection, get the document, and get the document number.Dim objIManageExtensibility As iManO2K.iManageExtensibility' An object used for extending the functionality of WorkSite Office 2000' integration.' Get the WorkSite O2K extensibility object.Set objIManageExtensibility = _Application.COMAddIns("iManO2K.AddinForWord2000").Object'Check connectionIf objIManageExtensibility.CurrentMode = nrConnectedMode ThenDim objDocument As IManage.IManDocument'Get documentSet objDocument = objExtensibilitySink.GetDocumentFromPath(Word.Acti veDocument.FullName)If Not objDocument Is Nothing Then'Display doc number to demonstrate how to get document profile infoMsgBox objDocument.GetAttributeByID(imProfileDocNum) & "_" & objDocument.GetAttributeByID(imProfileVersion)Set objDocument = NothingEnd IfEnd If The methods to insert the document property input to a document is through WOM. So that's up to you to use WOM to get this done. Likewise, you would use WOM for removing stuff that you have inserted to the document.
This is great, thanks!Now, where do I add this code? Will this be in a new .dot file or within the custft8xEAI-e.dot file? Is it part of a module or a class module (I'm not even sure I understand the difference)?Thanks again!Andreas
As previously explained, you would add this code to your own macro or COM-AddIn.
Set objIManageExtensibility = _Application.COMAddIns("iManO2K.AddinForWord2000").Object
When i do that, I get a Compile error: Invalid outside procedureMessageat Set objIManageExtensibility = _Application.COMAddIns("iManO2K.AddinForWord2000").Object Something else must be missing.
Did you reference the type lib for iman2ok.dll? Did you dimension the objIManageExtensibility var? I can't tell where this code is located inside your code. It looks like you have put the set statement somewhere in an illegal area of the code, like in the declaration area.
:-)You're assuming I know a lot more than I do. How do I do the things you mention?I don't see it in the code of the other macro.