Page 1 of 1 1
Topic Options
#91572 - 2003-02-21 08:38 PM COM and WORD
Tedd Webb Offline
Lurker

Registered: 2003-02-21
Posts: 2
Loc: Orange, California
HELP!

We need a quick way to update the workgroup template path for MS Word via KiXstart.

We have Office 97, 2000 and XP, so we would rather not have to go through all the various registry keys to check the version of office. Instead, we have a VBScript that automatically updates the Workgroup Templates path. This code works fine in VBA, VB, and VBScript. However, when it was ported to KiXstart, it does not work. No errors are produced, but the code does not change the workgroup template path.

HELP!

;VBScript Syntax works 100%
;Set wrd = CreateObject("Word.Application")
;wrd.Visible = False
;wrd.Options.DefaultFilePath(3) = "\\Procom2\wab\Tech Serv\"
;wrd.Quit
;Set wrd = Nothing

;Corresponding KiXstart code does not work.
;WHY? Undocumented/missing syntax or bug or what?
$wrd = CreateObject("Word.Application")
? ''+@ERROR+' - '+@SERROR ;returns "The Operation Completed Successfully"
$wrd.Visible = 0
$wrd.Options.DefaultFilePath(3) = "\\Procom2\wab\Tech Serv\"
? ''+@ERROR+' - '+@SERROR ;returns "The Operation Completed Successfully"
$wrd.Quit
$wrd = 0

Top
#91573 - 2003-02-22 12:18 AM Re: COM and WORD
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Hi Tedd, welcome to KORG

In short - this particular "flavor" of COM syntax is not supported in Kixtart. I asked Ruud about this a while back, heres a copy of the note:

quote:

Ruud,

Just been scratching my head over another COM problem ... think this has been a problem since day one ... just that its not used too often ...

This works ok (see it all the time in Excel COM) :

$object.property("parm").value = 1

but this does not work:

$object.property("parm") = 1

that is to say, a property with parms that is NOT nested ... seems to do a GET_PROPERTY first, than does a BAD PUT_PROPERTY ... again, component tested with VB/VBS and verified ok ... 4.02 has idential behavior.

-Shawn

Ruud replied:

Well, as you know, I dropped puts of default properties, so the second example will never work.

The GetProperty you are seeing is for the IDispatch interface of '.property("parm")'. The failed put occurs when KiX tries to write to '.property("parm")'.

I know VB supports this kind of code, but at the cost of the SET command. Without a SET command, there is no way to tell what you want code like this to do.

--Ruud

No consolation here but at least an explaination - not supported.

-Shawn

Top
#91574 - 2003-02-26 07:35 PM Re: COM and WORD
Tedd Webb Offline
Lurker

Registered: 2003-02-21
Posts: 2
Loc: Orange, California
Thanks for the info. I guess we'll have to start looking into another login scripting program then because we are starting to implement this style of syntax commands more often.

Oh, well!

Thanks,

Tedd

Top
#91575 - 2003-02-26 07:49 PM Re: COM and WORD
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Why do you need to look for another login scripting program? Is it too hard to code the script correctly and following the syntax rules?
_________________________
There are two types of vessels, submarines and targets.

Top
#91576 - 2003-02-26 07:54 PM Re: COM and WORD
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
First off, what you are looking to do is not really what logon scripts are for. Second, there is no reason why you could not shell out to 'cscript' from KiX and and run your vbscript.

If you want to do your logon scripting in another language that is entirely your prerogative. Whatever other language you choose will invariably be more effort that working around a minor limitation like this.

My two cents...
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#91577 - 2005-11-21 07:22 PM Re: COM and WORD
mactune Offline
Just in Town

Registered: 2005-04-25
Posts: 4
Loc: Orlando Florida
I am interested in reading/setting the file location in word

I found this the following script here: scripting guy

Code:
   
Const wdUserTemplatesPath = 2
Const wdWorkgroupTemplatesPath = 3

Set objWord = CreateObject("Word.Application")
Set objOptions = objWord.Options

objOptions.DefaultFilePath(wdUserTemplatesPath) = "C:\Templates"
objOptions.DefaultFilePath(wdWorkgroupTemplatesPath) = "C:\Workgroup\Templates"

objWord.Quit



-- this is what i came up with for reading the parameters- but it doesn't return anything. i know i'm missing something .... any ideas?
Code:
  
$objWord = CreateObject("word.Application")
$objOptions = $objWord.Options
$objPath = $objOptions.DefaultFilePath
For Each $obj in $objPath
? "$obj"
Next


Top
#91578 - 2005-11-21 07:27 PM Re: COM and WORD
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
The property $objOptions.DefaultFilePath by itself returns an EMPTY reference, need to provide in indexer to pull exactly what you want, like this:

?"path=" + $objOptions.DefaultFilePath(0)

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 476 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.057 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org