Windows2000,Word2003,ASP.Net - Help

E

Elizabeth Harmon

Hi All

I am attempting to open a Word App from a web page on the client and so far
everything
works (After reconfig of dcomcnfg for Microsoft Word Document). I have one
minor problem, i cannot get the application to become visible
**********What am i doing wrong? is there something else that needs to be
done to make the application visible? I am using windows 2000 and Word 2002

thanks in advance

Samantha

Below is the Code i am using:
Class Declarations:

Public WrdApp As Word.ApplicationClass

Public wrdLetter As Word.Document



In Private Sub :

If WrdApp Is Nothing Then
WrdApp = New Word.ApplicationClass

WrdApp.Visible = True

WrdApp.WindowState=Word.WdWindowState.wdWindowStateMaximize

End If

wrdLetter = New Word.Document

Dim strNewFilePath As String = "C:\Temp\"

Dim strUniqId As String = Date.Now.Hour.ToString() &
Date.Now.Minute.ToString()

Dim NewFileName As String = strPatientName.Replace(" ", "-").ToString() &
CStr(FormatDateTime(Date.Now, DateFormat.ShortDate)).Replace("/", "-") &
strUniqId.Replace(":", "-") & ".doc"

Dim missing As Object

missing = System.Reflection.Missing.Value

wrdLetter = WrdApp.Documents.Open(fileName, missing, readonlyAcc, True,
missing, missing, missing, missing, missing, missing, missing, isVisible,
missing, missing)

wrdLetter.Activate()

wrdLetter.Bookmarks.Item("TodayDate").Range.Text =
FormatDateTime(Date.Now(), DateFormat.ShortDate)

wrdLetter.Bookmarks.Item("PatientNM").Range.Text = strPatientName

wrdLetter.Bookmarks.Item("SSN").Range.Text = strPatientSSN

wrdLetter.Bookmarks.Item("PCP").Range.Text = strEval

wrdLetter.Bookmarks.Item("Location").Range.Text = strLocationName

wrdLetter.Bookmarks.Item("TeacherNM").Range.Text = strTeacherName

wrdLetter.SaveAs(strNewFilePath & NewFileName)

wrdLetter.PrintPreview()

'WrdApp_DocumentBeforeClose(wrdLetter, False)

wrdLetter.Close()

System.Runtime.InteropServices.Marshal.ReleaseComObject(wrdLetter)

wrdLetter = Nothing

WrdApp.Application.Quit()

System.Runtime.InteropServices.Marshal.ReleaseComObject(WrdApp)

WrdApp = Nothing

fileName = Nothing

isVisible = Nothing

readonlyAcc = Nothing
 
M

Martin

This is typically an identity issue. If you mess with DCOMCNFG and you
want a GUI to pop up, make sure the application is run by "the interactive
user". You can set this on the Identity tab of DCOMCNFG properties.

From a DCOM perspective, the interactive user "owns" the GUI, hence
any (pseudo-)remote clients will not get access to the GUI when calling
services with their own identity.
 
E

Elizabeth Harmon

Does this mean that i should Make the ASP_NET user or the IUSR_MAchineName
part of another group that has rights to Use the GUI and Application?

Thanks in advance
Samantha
 
M

Martin

Samantha,

I am not quite sure what you are trying to do, the problem just sounded
familiar and I guessed I would put you on the right track by telling you
about the identity of the launching user. Perhaps I just sent you further
into the woods.
Does this mean that i should Make the ASP_NET user or the IUSR_MAchineName
part of another group that has rights to Use the GUI and Application?

I don't think you can delegate the right to use the GUI to anyone but the
logged on user. This is why the very action is delegated to the logged on
user.

Re-reading your earlier message I understand you want to open a Word
document (which is located on the server) on the client, outside of your
browser, by automating Word through client side script.

If this is the case, IUSR_MachineName isn't of much use since it lives on
the server. The client side script code should be executed under your
visitor's account, the one that started the browser, which is the
interactive user on the client side. I don't see an identity issue there.

Now I believe the problem is in the way you address word from script. There
should be a method or property on the "Word.Application" object that tells
it to show a GUI or not.

http://msdn.microsoft.com/library/d...dv_wrcore/html/wrgrfapplicationproperties.asp

Try theVisible property and forget about DCOMCNFG altogether..
 
M

Martin

The client side script code should be executed under your
visitor's account, the one that started the browser, which is the
interactive user on the client side. I don't see an identity issue there.

This had better not be true since it would enable a web site developer
to erase the visitor's local hard disk using client side script. I am not
too confident in this area. Anyway, check out that Visible
property.

Martin.
 
E

Elizabeth Harmon

Martin

Thanks for your help.

I am passing back information From the Server to a web page, and then
Opening Word on the Client side and then filling bookmarks on the Word
Template that is located on the Client in an intranet website, with the code
below:

*****************************************************************
If WrdApp Is Nothing Then
WrdApp = New Word.ApplicationClass

WrdApp.Visible = True

WrdApp.WindowState=Word.WdWindowState.wdWindowStateMaximize

End If

wrdLetter = New Word.Document

Dim strNewFilePath As String = "C:\Temp\"

Dim strUniqId As String = Date.Now.Hour.ToString() &
Date.Now.Minute.ToString()

Dim NewFileName As String = strPatientName.Replace(" ", "-").ToString() &
CStr(FormatDateTime(Date.Now, DateFormat.ShortDate)).Replace("/", "-") &
strUniqId.Replace(":", "-") & ".doc"

Dim missing As Object

missing = System.Reflection.Missing.Value

wrdLetter = WrdApp.Documents.Open(fileName, missing, readonlyAcc, True,
missing, missing, missing, missing, missing, missing, missing, isVisible,
missing, missing)

wrdLetter.Activate()

wrdLetter.Bookmarks.Item("TodayDate").Range.Text =
FormatDateTime(Date.Now(), DateFormat.ShortDate)

wrdLetter.Bookmarks.Item("PatientNM").Range.Text = strPatientName

wrdLetter.Bookmarks.Item("SSN").Range.Text = strPatientSSN

wrdLetter.Bookmarks.Item("PCP").Range.Text = strEval

wrdLetter.Bookmarks.Item("Location").Range.Text = strLocationName

wrdLetter.Bookmarks.Item("TeacherNM").Range.Text = strTeacherName

wrdLetter.SaveAs(strNewFilePath & NewFileName)

wrdLetter.PrintPreview()

'WrdApp_DocumentBeforeClose(wrdLetter, False)

****************************************************************************
*****

I can send the information, the word doc file gets its bookmarks filled and
it is saved on the local client, the only thing missing is the GUI of Word
which never appears to become visible even though i issue a Visible = true
propety of the Word App.

What i want is for the User to see the document so they can review it or
make any changes to the document. I have disabled the interactive user for
an indentity that has full rights to the Client machine, i just dont
understand why the Visible property is not being understood.

Thanks in advance
Samantha
 
M

Martin

Okay, here's another thought.

You seem to start Word as a COM server by obtainig an interface. Then you
talk to the interface and I presume the client side script runs out of scope
at some point. That would be the time for the script interpreter to release
the interface if you had not done so yourself by setting your WrdApp to
Nothing. Word would notice there are no COM clients left and would
terminate. The whole thing could be going so fast that you would never see
the Word GUI.

If this is indeed what is happening, it would help to just start Word before
the firt interface is obtained through

WrdApp = New Word.ApplicationClass


Does it work the way you want it to if Word is already up before the script
kicks in? If so, you need to have the script start a Word instance if it not
already there. I don't want to start thinking about how to do that yet.

Better yet would be to have some sort of client side session object to store
your WrdApp in , preventing it from running out of scope.

I hope this makes any sense.

Martin.
 
E

Elizabeth Harmon

Martin

It may be the case that the word object is coming and going so fast that i
just dont see it, I may have to use some form of thread.sleep() to hold it
open for a bit. I am getting everything accomplished except a visual on
word, the letter is made and saved complete with passsed information, I just
never see it.

Thanks for your help

I'll get back with you
Samantha
 
E

Elizabeth Harmon

Changing the COM User to The Interactive User Worked and the Word app
appeared like i needed so thanks for all your help

Samantha
 
M

Martin

Samantha,
Changing the COM User to The Interactive User worked

Groovy. Note that if you need to configure this for several workstations you
can do so automatically by changing the registry according to the following
import file:

---------------------------------------
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\AppID\{00020906-0000-0000-C000-000000000046}]
@="Microsoft Word Document"
"AuthenticationLevel"=dword:00000000
"RunAs"="Interactive User"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AppID\{00020906-0000-0000-C000-00000000
0046}]
@="Microsoft Word Document"
"AuthenticationLevel"=dword:00000000
"RunAs"="Interactive User"
---------------------------------------

I assume the GUID will be identical for different Word versions but you may
want to verify that (I copied it from the DCOMCNFG's property window's
General tab and did a search for it in the registry). Launching user is
default, if you change it in the GUI and hit F5 in RegEdit you will see the
new setting appear.

Martin.
 
E

Elizabeth Harmon

thanks again Martin!!
Martin said:
Samantha,
Changing the COM User to The Interactive User worked

Groovy. Note that if you need to configure this for several workstations you
can do so automatically by changing the registry according to the following
import file:

---------------------------------------
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\AppID\{00020906-0000-0000-C000-000000000046}]
@="Microsoft Word Document"
"AuthenticationLevel"=dword:00000000
"RunAs"="Interactive User"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AppID\{00020906-0000-0000-C000-00000000
0046}]
@="Microsoft Word Document"
"AuthenticationLevel"=dword:00000000
"RunAs"="Interactive User"
---------------------------------------

I assume the GUID will be identical for different Word versions but you may
want to verify that (I copied it from the DCOMCNFG's property window's
General tab and did a search for it in the registry). Launching user is
default, if you change it in the GUI and hit F5 in RegEdit you will see the
new setting appear.

Martin.


Elizabeth Harmon said:
Changing the COM User to The Interactive User Worked and the Word app
appeared like i needed so thanks for all your help

Samantha
that
hold
it I
just Then
you never
see
if
it with
the "-")
**************************************************************************** Visible
= it I
am
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top