Rooster10
(Fresh Scripter)
2005-12-23 12:44 PM
Open Doc

Hi,

I have a Kixform running which maps a network drive and I want it to open up a word document, the form works, the drive maps, however the doc won't open, I think there is something not right with the run "g:\test.doc", can anyone help?

Cheers

Break On
$System = CreateObject("Kixtart.System")
;create form
$Form = $System.Form()
$Form.BackColor = 212,208,200
$Form.FontSize = 8,25
$Form.Height = 187
$Form.Left = 200
$Form.Text = "Documentation Tool"
$Form.Top = 110
$Form.Width = 275

;create pulldown menu
$ComboBox = $Form.Controls.ComboBox()
$ComboBox.DropDownWidth = 121
$ComboBox.FontSize = 8,25
$ComboBox.Height = 21
$ComboBox.Left = 50
$ComboBox.Sorted = "False"
$ComboBox.Text = "Select Document"
$ComboBox.Top = 60
$ComboBox.Width = 148
$ComboBox.AddItem ("EPC - With Kerridge DMS")

;create button
$Button = $Form.Controls.Button()
$Button.FontSize = 8,25
$Button.Height = 30
$Button.Left = 50
$Button.Text = "Map Document Drive G:"
$Button.Top = 20
$Button.Width = 110
$Button.OnClick = "Button_Map()"

;create button
$Button = $Form.Controls.Button()
$Button.FontSize = 8,25
$Button.Height = 28
$Button.Left = 50
$Button.Text = "Open Document"
$Button.Top = 100
$Button.Width = 110
$Button.OnClick = "Button_Open()"


$Form.Show
While $Form.Visible
$=Execute($Form.DoEvents())
Loop
Exit 1

Function Button_Click()
$app = $comboBox.text
Select
Case $app = "Select Document"
$rc = MessageBox("No Doc Selected.","Error",16,0)
EndSelect
Endfunction

Function Button_Open()
$app = $comboBox.text
Select

Case $app = "EPC - With Kerridge DMS"
Run "g:\test.doc"

EndSelect
Endfunction



$Form.Show
While $Form.Visible
$=Execute($Form.DoEvents())
Loop
Exit 1
;
Function Button_Map()
Use g: '\\szgb06\company\Dealers\Documents'
EndFunction


LonkeroAdministrator
(KiX Master Guru)
2005-12-23 01:15 PM
Re: Open Doc

yes, doc is not registered extension, thus it can't be ran.
hmm...
try:
run 'explorer "g:\test.doc"'


Rooster10
(Fresh Scripter)
2005-12-23 01:16 PM
Re: Open Doc

Excellent help, many thanks, it works !

Mart
(KiX Supporter)
2005-12-23 01:39 PM
Re: Open Doc

More safe solution just in case .doc is not associated to winword.exe and more then one word version is used.

Code:

$File = "G:\test.doc"
$App = "WinWord.exe"
$WordPath = ReadValue ("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe", "Path")
Run $WordPath + "\" + $App + " " + $File



LonkeroAdministrator
(KiX Master Guru)
2005-12-23 02:42 PM
Re: Open Doc

actually, does not make that much safer.
word checks the versioning and file assocs every time it runs, no?

but yes, this is nicer way of doing it.


Mart
(KiX Supporter)
2005-12-23 02:51 PM
Re: Open Doc

You're right the version of word has nothing to do with it in this case.
I’ve been working on a script to determine the installed office version. Stuff was still spinning around in my head I guess.


LonkeroAdministrator
(KiX Master Guru)
2005-12-23 02:57 PM
Re: Open Doc

stuff don't spin in my head that much but in my stomach instead :P

Mart
(KiX Supporter)
2005-12-23 03:39 PM
Re: Open Doc

LOL