#179835 - 2007-08-28 12:58 PM
Small VBS script to Kix
|
Chelseauk
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
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
|
|
|
|
#179841 - 2007-08-28 01:18 PM
Re: Small VBS script to Kix
[Re: Witto]
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
$objOptions.DefaultFilePath(wdStartupTemplatesPath) = "C:\Brand Templates\startup"
$objOptions.DefaultFilePath(wdWorkgroupTemplatesPath) = "C:\Brand Templates" Oops. You need to fix up your "constants" ($ prefix)
|
|
Top
|
|
|
|
#179843 - 2007-08-28 01:45 PM
Re: Small VBS script to Kix
[Re: Witto]
|
Chelseauk
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
|
|
|
|
#179847 - 2007-08-28 01:59 PM
Re: Small VBS script to Kix
[Re: Björn]
|
Chelseauk
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
|
|
|
|
#179853 - 2007-08-28 02:52 PM
Re: Small VBS script to Kix
[Re: Chelseauk]
|
Witto
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
|
|
|
|
#179857 - 2007-08-28 03:28 PM
Re: Small VBS script to Kix
[Re: Richard H.]
|
Chelseauk
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
|
|
|
|
#179873 - 2007-08-28 05:06 PM
Re: Small VBS script to Kix
[Re: Witto]
|
Chelseauk
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
|
|
|
|
#179913 - 2007-08-29 08:40 AM
Re: Small VBS script to Kix
[Re: Witto]
|
Arend_
MM club member
   
Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
|
Probably this will work:
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 302 anonymous users online.
|
|
|