Page 1 of 1 1
Topic Options
#179835 - 2007-08-28 12:58 PM Small VBS script to Kix
Chelseauk Offline
Fresh Scripter

Registered: 2007-08-28
Posts: 6
Hi,

I need to convert a small .vbs (7 Lines) script to kix - and don't do vbs. I realise it's a major cheek - but it's a one time only need (I hope) - any chance a kix/Vbs wizz could have a quick look and give me a hand.


Const wdStartupTemplatesPath = 7
Const wdWorkgroupTemplatesPath = 3

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

objOptions.DefaultFilePath(wdStartupTemplatesPath) = "C:\Brand Templates\startup"
objOptions.DefaultFilePath(wdWorkgroupTemplatesPath) = "C:\Brand Templates"

objWord.Quit

Top
#179838 - 2007-08-28 01:06 PM Re: Small VBS script to Kix [Re: Chelseauk]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
I did not try this!!! Just tried to convert
; ===========================================================================================
;
;     Script Information
;    
;     Title:       SetWordOptions
;     Author:      Wim Rotty
;     Description: Converted from vbscript provided by Chelseauk
;    
;
; ===========================================================================================
;Script Options

If Not @LOGONMODE
   Break On
Else
   Break Off
EndIf
Dim $RC
$RC = SetOption("Explicit", "On")
$RC = SetOption("NoMacrosInStrings", "On")
$RC = SetOption("NoVarsInStrings", "On")
If @SCRIPTEXE = "KIX32.EXE"
   $RC = SetOption("WrapAtEOL", "On")
EndIf

;Declare variables
Dim
 
$wdStartupTemplatesPath, $wdWorkgroupTemplatesPath
Dim $objWord, $objOptions

;Initialize variables
$wdStartupTemplatesPath = 7
$wdWorkgroupTemplatesPath = 3
$objWord = CreateObject("Word.Application")
If @ERROR
   Exit @ERROR
EndIf
$objOptions = $objWord.Options

;Code
$objOptions.DefaultFilePath($wdStartupTemplatesPath) = "C:\Brand Templates\startup"
$objOptions.DefaultFilePath($wdWorkgroupTemplatesPath) = "C:\Brand Templates"
$objWord.Quit


Edited by Witto (2007-08-28 01:30 PM)
Edit Reason: Forgot some $-signs

Top
#179839 - 2007-08-28 01:10 PM Re: Small VBS script to Kix [Re: Chelseauk]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
Might be totally off the chart here - but give something like this a wirl -
 Code:
;to laaate ;)
;my guess was something like:
$wdStartupTemplatesPath = 7
$wdWorkgroupTemplatesPath = 3

$ObjWord=CreateObject("Word.Application")
$ObjOptions=$objWord.Options
$objOptions.DefaultFilePath($wdStartupTemplatesPath)="C:\Brand Templates\startup"
$objOptions.DefaultFilePath($wdWorkgroupTemplatesPath)="C:\Brand Templates"
$objWord.Quit



Edited by Björn (2007-08-28 01:21 PM)
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#179841 - 2007-08-28 01:18 PM Re: Small VBS script to Kix [Re: Witto]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Code:
$objOptions.DefaultFilePath(wdStartupTemplatesPath) = "C:\Brand Templates\startup"
$objOptions.DefaultFilePath(wdWorkgroupTemplatesPath) = "C:\Brand Templates"

Oops. You need to fix up your "constants" ($ prefix)

Top
#179842 - 2007-08-28 01:31 PM Re: Small VBS script to Kix [Re: Richard H.]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Thanks Richard, changed the post
Top
#179843 - 2007-08-28 01:45 PM Re: Small VBS script to Kix [Re: Witto]
Chelseauk Offline
Fresh Scripter

Registered: 2007-08-28
Posts: 6
Guys thanks for the help - and i'm sure i'm being thick (but this is way beyond anything i've tried to do in kix)

I'm getting syntax errors on :-

$objOptions.DefaultFilePath($wdStartupTemplatesPath) = "C:\Brand Templates\startup"
$objOptions.DefaultFilePath($wdWorkgroupTemplatesPath) = "C:\Brand Templates"

I've had a play and can't spot it - any ideas ? I've tried droping the spaces and going short on the "C:\Brand Templates\startup" bits just in case.


Edited by Chelseauk (2007-08-28 01:47 PM)

Top
#179844 - 2007-08-28 01:50 PM Re: Small VBS script to Kix [Re: Chelseauk]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
urrr..
My first guess was:
 Code:
$objOptions.DefaultFilePath("C:\Brand Templates\startup")
$objOptions.DefaultFilePath("C:\Brand Templates")

But that doesn't look right..


Edited by Björn (2007-08-28 01:51 PM)
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#179847 - 2007-08-28 01:59 PM Re: Small VBS script to Kix [Re: Björn]
Chelseauk Offline
Fresh Scripter

Registered: 2007-08-28
Posts: 6
Hmmmm - perhaps not so simple...

No syntax now - just doesn't do anything.

The code is meant to change file locations in Word (templates directory).

Maybe i should just change the registry settings !

Top
#179848 - 2007-08-28 02:00 PM Re: Small VBS script to Kix [Re: Björn]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
These things can also be set with a simple registry setting. There is no real need for com scripting imho. Setting it on one system and running regshot will tell you what to set.

Have a look at these registry places.

 Quote:

HKU\[sid]\Software\Microsoft\Office\11.0\Common\General\SharedTemplates
HKU\[sid]\Software\Microsoft\Office\11.0\Word\Options\STARTUP-PATH
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#179849 - 2007-08-28 02:01 PM Re: Small VBS script to Kix [Re: Chelseauk]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
ya.. and with what I thought first it has no idea of what do alter, that's what your variables tells it. Naah, you should hold on a few to get a propper response ;\)
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#179853 - 2007-08-28 02:52 PM Re: Small VBS script to Kix [Re: Chelseauk]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Indeed not so simple
I would think that 7 is the wdTutorialPath
But I would write it like I did
It just does not seem to work. Is this one of the VB script examples that cannot eb converted to KiX?
Word Enumerated Constants

Top
#179855 - 2007-08-28 03:05 PM Re: Small VBS script to Kix [Re: Witto]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
Witto, I love you. that was a great link.
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#179856 - 2007-08-28 03:23 PM Re: Small VBS script to Kix [Re: Witto]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
 Originally Posted By: Witto
Indeed not so simple
I would think that 7 is the wdTutorialPath
But I would write it like I did
It just does not seem to work. Is this one of the VB script examples that cannot eb converted to KiX?
Word Enumerated Constants


Did you try it as a VB script to see if that works?

Top
#179857 - 2007-08-28 03:28 PM Re: Small VBS script to Kix [Re: Richard H.]
Chelseauk Offline
Fresh Scripter

Registered: 2007-08-28
Posts: 6
VB Script works fine - but i don't think you call them from Kix ?? - or so the forum search i did - seem to suggest.
Top
#179863 - 2007-08-28 04:19 PM Re: Small VBS script to Kix [Re: Chelseauk]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
I would think
Run or Shel
something like
Shell 'WScript MyScript.vbs'

Top
#179873 - 2007-08-28 05:06 PM Re: Small VBS script to Kix [Re: Witto]
Chelseauk Offline
Fresh Scripter

Registered: 2007-08-28
Posts: 6
Well that works - see shouldn't have believed what i found on the search (as it all seemed to say convert it to kix).

- Your all very nice people - so Big Thanks for all your help !!!!

Top
#179878 - 2007-08-28 05:42 PM Re: Small VBS script to Kix [Re: Chelseauk]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
I still would say, convert it to KiX, just to have all in the same script language.
But maybe it is impossible?

Top
#179913 - 2007-08-29 08:40 AM Re: Small VBS script to Kix [Re: Witto]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Probably this will work:
 Code:
Dim $wdStartupTemplatesPath = 7
Dim $wdWorkgroupTemplatesPath = 3

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

$objOptions.DefaultFilePath($wdStartupTemplatesPath).Value = "C:\Brand Templates\startup"
$objOptions.DefaultFilePath($wdWorkgroupTemplatesPath).Value = "C:\Brand Templates"
$objWord.Quit

Top
#179928 - 2007-08-29 11:33 AM Re: Small VBS script to Kix [Re: Arend_]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Arend,
Nope,
.Value does not seem to work.
I also cannot find anything of .Value for DefaultFilePath() via an Object Browser...

Top
#179930 - 2007-08-29 11:56 AM Re: Small VBS script to Kix [Re: Witto]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Maybe I don’t get it but the default file path and the path to the various templates can also be set with some simple registry settings in lets say a logon script so why should one use a complicated com script?
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 302 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.074 seconds in which 0.024 seconds were spent on a total of 13 queries. Zlib compression enabled.

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