![]() |
Telelogic SYNERGY (steve huntington) | ![]() |
Topic Title: Keywords in Office files Topic Summary: Created On: 1-Jul-2004 16:30 Status: Read Only |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() Answer: Hi Mert, Sorry for taking so long to reply. Your solution works like a charm. Had some trouble with your 'Wait for process termination... ', but have altered this a bit. Followed your lead on the rest of the code. Result: When editing (so not when only viewing) an object of the type 'ms_word' a Word macro is started which collects the versionnumber of the object and it's author/resolver, writes it into custom document properties and updates all fields in the entire document that refer to these custom document properties. Thanks for your effort. | |
![]() |
|
Hi all,
I'm looking for a way to automatically update filehandles (i.e. keywords like %name% and %version%) in Office documents, mainly Word files. We just migrated from CS-RCS, which does allow filehandles to be maintained by the CS-RCS database. I must admit. CS-RCS uses an .dot file (supplied with the standard installation of CS-RCS) and predefined document properties. Should I look for a solution like writing a macro for Word that updates predefined document properties from CM Synergy keywords? If so, how do I go about accessing the CM Synergy keywords? Regards, Danny ------------------------- Regards, Danny |
|
![]() |
|
![]() |
|
Hi Danny !
Well, a makro whould be one way to do that. Access to the properties could be done e.g by the ccm dir <Dokumentname> -f %ATTRIBNAME1 %ATTRIBNAME2 ... function. You could run this commandline via a VB Exec command. Unfortunatelly you might use a file created with a redirector ">" to get the result of the query. At least it works, too. The more elegant way, would be to use a helper function which gives back standard output to a variable. Thats the way I normally do that.... The other way would be to use a checkout/checkin trigger script for word documents to do that. Here you might use VbScripting and Office object model stuff to manipulate the document directly. Perhaps a combined method is possible, too. Let the trigger script write desired attributes to a defined location with a defined filename, e.g. DokName_Attrib. When the user opens the document start a macro, which loads those stored attributes. Just some thoughts... Regards, Mert |
|
![]() |
|
![]() |
|
Thanks Mert,
I'll try some of your suggestions. One question though: I'm new to Synergy, so what do you mean with "helper function"? Regards, Danny ------------------------- Regards, Danny |
|
![]() |
|
![]() |
|
Hi !
Helper function: Just a function e.g. called cmdlinexe(argument) written in VB too, which does the logic to execute a commandline given as the argument and return the result (the output of the commandline normally sent to stdout). There are several suggestions to do things like that with VB in the MSDN library. If there is interest in further help, just give a sign ![]() Regards, Mert |
|
![]() |
|
![]() |
|
Hi !
I have tested this office keyword stuff and it works quite well. The autoopen marco calls a functions which uses the ccm info command to get infomation about the document at sets appropriate properties... On interest I could send the central "helper" function to this board. Regards, Mert |
|
![]() |
|
![]() |
|
Hi Mert,
Just got back from my holiday, didn't have time to experiment. Yes, I'm interested, ofcourse. I would like to see your implementation, please. Regards, Danny. ------------------------- Regards, Danny |
|
![]() |
|
![]() |
|
Hi Danny !
Sorry for delay... Hope You had a pretty time far away from config-management. The fellowing is a code snippet showing a very basic implementation of a function to wait for a command to be finished and store command output into a variable. At least to wait for the process to be terminated is the most important thing. It can be placed into a module of any office document or in a seperate VB project in order to create a widely usable COM server.... To get cm synergy document properties send a command like ccm dir -f %version% <ActiveDocument.Fullname> and store the result to ActiveDocument.BuiltInDocumentProperties (collection which hold property information). There are many other ways to implement this "output" retrieval. Normally I use a version without a output file, but with stdout and stderr redirected to user pipes, which is slighly more complicate but also slightly faster because you dont have to deal with files.... I would recommend to take look at the MSDN knowledgebase, as there is a bunch of information there dealing with this topic. As I am preparing a presentation dealing with the CM Synergy scripting topic in general, I might provide some more stuff lateron.... ---------------------------------------------------------------------------- Private Declare Function OpenProcess Lib "kernel32.dll" (ByVal _ dwAccess As Long, ByVal fInherit As Integer, ByVal hObject _ As Long) As Long Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _ hHandle As Long, ByVal dwMilliseconds As Long) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal _ hObject As Long) As Long Sub AutoOpen() ' Autostart Makro MsgBox "CCM Version:" & vbCrLf & _ ShellCmd("ccm version") End Sub Public Function ShellCmd(cmdline As String) As String Dim ProcessID As Long, ProcessHandle As Long Dim output As String, tmpstr As String Dim lfile As Long If Len(cmdline) = 0 Then Exit Function If LCase(Left(cmdline, 4)) <> "cmd " Then cmdline = "cmd /c " & cmdline cmdline = cmdline & " 1> testout.txt 2> testerr.txt" ProcessID = Shell(cmdline, vbHide) ProcessHandle& = OpenProcess(SYNCHRONIZE, True, ProcessID&) ' Wait for process termination.... Do ret = WaitForSingleObject(ProcessHandle&, -1&) DoEvents Loop Until ret <> 258 CloseHandle ProcessHandle& ' Read command output output = "" On Error GoTo Error If FileLen("out.dat") > 0 Then lFile = FreeFile Open "out.dat" For Input As lFile Do Line Input #lfile, tmpstr output = output & tmpstr & vbCrLf Loop Until EOF(lfile) Close lfile End If If FileLen("err.dat") > 0 Then lfile = FreeFile Open "err.dat" For Input As lfile Do Line Input #lfile, tmpstr output = output & tmpstr & vbCrLf Loop Until EOF(lfile) Close lfile End If ShellCmd = output Kill ("out.dat") Kill ("err.dat") Exit Function Error: ShellCmd = "" MsgBox Err.Number & " " & Err.Description & vbCrLf & Err.Source End Function ---------------------------------------------------------------------------- Best regards, Mert |
|
![]() |
|
![]() |
|
Hi Mert,
Your delay wasn't a problem. Yes, I had a great time (no telephone, no computer *Aaahh... Heaven* ![]() Thanks for the snippet. I'll try it out and let you know the final results. Good luck with your presentation. Kind regards, Danny ------------------------- Regards, Danny |
|
![]() |
|
![]() |
|
Hi Mert,
Sorry for taking so long to reply. Your solution works like a charm. Had some trouble with your 'Wait for process termination... ', but have altered this a bit. Followed your lead on the rest of the code. Result: When editing (so not when only viewing) an object of the type 'ms_word' a Word macro is started which collects the versionnumber of the object and it's author/resolver, writes it into custom document properties and updates all fields in the entire document that refer to these custom document properties. Thanks for your effort. ------------------------- Regards, Danny |
|
![]() |
Telelogic SYNERGY
» SYNERGY/CM
»
Keywords in Office files
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.