Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic SYNERGY (steve huntington)
Decrease font size
Increase font size
Topic Title: Keywords in Office files
Topic Summary:
Created On: 1-Jul-2004 16:30
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
Answer This question was answered by Danny Beerens, on Wednesday, September 8, 2004 1:14 PM

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.
 1-Jul-2004 16:30
User is offline View Users Profile Print this message


Danny Beerens

Posts: 18
Joined: 3-Jun-2004

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
Report this to a Moderator Report this to a Moderator
 3-Jul-2004 19:22
User is offline View Users Profile Print this message


Mert Vuraldi

Posts: 22
Joined: 2-Feb-2004

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
Report this to a Moderator Report this to a Moderator
 5-Jul-2004 09:55
User is offline View Users Profile Print this message


Danny Beerens

Posts: 18
Joined: 3-Jun-2004

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
Report this to a Moderator Report this to a Moderator
 5-Jul-2004 14:39
User is offline View Users Profile Print this message


Mert Vuraldi

Posts: 22
Joined: 2-Feb-2004

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
Report this to a Moderator Report this to a Moderator
 22-Jul-2004 14:45
User is offline View Users Profile Print this message


Mert Vuraldi

Posts: 22
Joined: 2-Feb-2004

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
Report this to a Moderator Report this to a Moderator
 26-Jul-2004 08:06
User is offline View Users Profile Print this message


Danny Beerens

Posts: 18
Joined: 3-Jun-2004

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
Report this to a Moderator Report this to a Moderator
 30-Jul-2004 21:51
User is offline View Users Profile Print this message


Mert Vuraldi

Posts: 22
Joined: 2-Feb-2004

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
Report this to a Moderator Report this to a Moderator
 3-Aug-2004 07:32
User is offline View Users Profile Print this message


Danny Beerens

Posts: 18
Joined: 3-Jun-2004

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
Report this to a Moderator Report this to a Moderator
 8-Sep-2004 13:14
User is offline View Users Profile Print this message


Danny Beerens

Posts: 18
Joined: 3-Jun-2004

Answer 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.


-------------------------
Regards,
Danny
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic SYNERGY forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 15:34.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.