Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perhaps an interesting question??? Or I'm just an idiot...

Status
Not open for further replies.

illbill

Programmer
Aug 29, 2001
2
US
I working in a system called ClearQuest. It allows the use of calling hooks written with VBScript but it is giving me some issues on this one particular piece.

I have created a listbox that when a button is pressed shows all the files in a particular directory.

Function templates_ShowFolderList(param)
' param As Variant
' record type name is Templates
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("c:\Templates")
Set fc = f.Files
For Each f1 in fc
s = s & f1.name
s = s & vbLf
' SetFieldValue "Template_Names", f1.name
Next
ShowFolderList = s
SetFieldValue "Template_Names", s
End Function

This works like a charm. Now I need another button on the form that allows the document selected to open when selected.

I've added the button and have been trying to get this to work using :

Function templates_GetDocument(param)
' param As Variant
' record type name is Templates
const lstrTemplatePath = "c:\Templates\"
Dim lstrOpenFile
Dim fso
Dim ts
Dim word_app
Dim template_file
Dim curr_document

lstrOpenFile = GetFieldValue("Template_Names").GetValue

template_file = lstrTemplatePath

set word_app = CreateObject("Word.Application")
set curr_document = word_app.Documents.Open template_file)
word_app.visible = true

End Function

I've been working on this for the last 15 hours or so and am beginning to go blind (and make stupid mistakes) so I was wondering if anyone had any thoughts...

MUCH MUCH Appreciated!!!!
Billy
 


illBill,

Just glancing at your code, you are missing a parenthesis.

set curr_document = word_app.Documents.Open template_file)

Should be:

set curr_document = word_app.Documents.Open (template_file)

Cheers,
fengshui1998
 
For whatever reason I must have deleted it when I posted to the forum but it exists in my code. Still no luck though ... and they just won't let me go home and sleep...:(

If anyone has any thoughts let me know!
Thanks in advance
Billy
 
illbill,

First thing I would do is try running your function as separate code to see if you can open up WORD with any file, and then use the template file name.

I also noticed one thing with MS apps is that if WORD or EXCEL is already open, you might have a problem seeing the document opened. Make sure that WORD is not already being used. Check "Task Manager" to see if it's already there.

Cheers,
fengshui1998
 
To work with the running/not running thing programatically I have used the following code. It is a bit hacky and I would appreciate advise on a better method but it works.


Err.Clear
On Error Resume Next
Set objXLS = Server.GetObject(, "Excel.Application")

'If the Excel Application does not exist, then create it
If Err.Number <> 0 Then
Set objXLS = Server.CreateObject(&quot;Excel.Application&quot;)
End If

On Error GoTo LocalErr


 
Hello, illbill.

Just wondering, should the line in your function Function templates_GetDocument(param):

template_file = lstrTemplatePath '_?????_

be read as

template_file = lstrTemplatePath & lstrOpenFile '_propose to look into it_

Otherwise, the function should work.
 
illbill:

Two things. Try going to the ClearQuest users group on Rational's site and see if anyone has a solution. It is a very helpful group.

Two. Try putting the code to open Word in a global script and put in a known doc to open in Word. Call it on a ValueChanged and see if it works.

Question: should

template_file = lstrTemplatePath

be

template_file = lstrTemplatePath & lstrOpenFile
?
It looks as though you may have a path but no file.

hth,

Parke
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top