Hi All
I am attempting to open a Word App from a web page 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.wdWindowStat eMaximize
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.ReleaseComO bject(wrdLetter)
wrdLetter = Nothing
WrdApp.Application.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComO bject(WrdApp)
WrdApp = Nothing
fileName = Nothing
isVisible = Nothing
readonlyAcc = NothingAre you trying to get Word to appear on the server or on the client?
This article demonstrates ways to interact with Excel & Word:
http://www.aspnetpro.com/Newsletter...p200309so_l.asp
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com
"Elizabeth Harmon" <EHarmon@.bloomingtonfarms.com> wrote in message
news:enMbUQctDHA.2932@.TK2MSFTNGP11.phx.gbl...
> Hi All
> I am attempting to open a Word App from a web page 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.wdWindowStat eMaximize
> 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.ReleaseComO bject(wrdLetter)
> wrdLetter = Nothing
> WrdApp.Application.Quit()
> System.Runtime.InteropServices.Marshal.ReleaseComO bject(WrdApp)
> WrdApp = Nothing
> fileName = Nothing
> isVisible = Nothing
> readonlyAcc = Nothing
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment