word editing is working in VB but not in ASP

Results 1 to 2 of 2

Thread: word editing is working in VB but not in ASP

  1. #1
    Join Date
    Dec 1969

    Default word editing is working in VB but not in ASP

    i have written a vb class as below.It is working fine when called through VB Form.<BR><BR>************************************* ******************<BR><BR>&#039;local variable(s) to hold property value(s)<BR>Private P_FileName As String &#039;local copy<BR><BR>Private MobjWordapp As Object<BR>Private MobjWordDocument As Word.Document<BR>&#039;local variable(s) to hold property value(s)<BR>Private P_Range As Range &#039;local copy<BR> Public Property Set MRange(ByVal vData As Range)<BR>&#039;used when assigning an Object to the property, on the left side of a Set statement.<BR>&#039;Syntax: Set x.Range = Form1<BR> Set P_Range = vData<BR> Set vData = Nothing<BR>End Property<BR><BR><BR>Public Property Get MRange() As Range<BR>&#039;used when retrieving value of a property, on the right side of an assignment.<BR>&#039;Syntax: Debug.Print X.Range<BR> Set MRange = P_Range<BR> <BR>End Property<BR><BR><BR><BR><BR>Public Property Let FileName(ByVal vData As String)<BR>&#039;used when assigning a value to the property, on the left side of an assignment.<BR>&#039;Syntax: X.FileName = 5<BR> P_FileName = vData<BR>End Property<BR><BR><BR>Public Property Get FileName() As String<BR>&#039;used when retrieving value of a property, on the right side of an assignment.<BR>&#039;Syntax: Debug.Print X.FileName<BR> FileName = P_FileName<BR>End Property<BR><BR><BR><BR><BR>Public Function ACTION(choice As Integer, Optional Sfileas As String)<BR> &#039;On Error GoTo errorhandler<BR>Select Case choice<BR><BR>Case 1 &#039;SAVEFILE<BR> &#039;Save the Located file<BR> MobjWordDocument.ActiveDocument.Save<BR> <BR>Case 2 &#039;SAVEFILEAS<BR> &#039;Save the Located file with new name or path<BR> <BR> MobjWordapp.ActiveDocument.SaveAs Sfileas<BR> MobjWordapp.ActiveDocument.Saved = True<BR> <BR>Case 3 &#039;CREATEFILE<BR> &#039;Create the New File<BR> Set MobjWordDocument = MobjWordapp.Documents.Open(P_FileName, , False)<BR>Case 4 &#039;OPENFILE<BR> Set MobjWordDocument = MobjWordapp.Documents.Open(P_FileName)<BR> &#039;Open the Existing files<BR> <BR>End Select<BR>Exit Function<BR>&#039;errorhandler:<BR>&#039;<BR>&#039 ; MobjWordDocument.Close<BR>&#039;<BR>&#039; Call Sleep(1000)<BR>&#039; MobjWordapp.Quit<BR>&#039; Set MobjWordDocument = Nothing<BR>&#039; Set MobjWordapp = Nothing<BR>End Function<BR><BR>Public Function SetWordRange(RTYpe As Integer, Optional DataRange As Object)<BR><BR> If RTYpe = 1 Then &#039;WHOLEFILE<BR><BR> Set MRange = MobjWordapp.ActiveDocument.Content<BR> <BR> With MRange<BR> .Start = 0<BR> .End = MobjWordapp.ActiveDocument.Characters.Count<BR> End With<BR><BR>End If<BR><BR>End Function<BR><BR>Public Sub InsertAtStart(Data As String)<BR><BR> Call SetWordRange(1)<BR> <BR> P_Range.InsertBefore (Data)<BR><BR>End Sub<BR>Public Sub InsertAtEnd(Data As String)<BR><BR> Call SetWordRange(1)<BR> <BR> P_Range.InsertAfter (Data)<BR><BR>End Sub<BR><BR>Private Sub Class_Initialize()<BR>CreateWordObject<BR>End Sub<BR><BR>Private Sub Class_Terminate()<BR>Dim obj As Word.Document<BR> &#039;MobjWordapp.ActiveDocument.Close<BR> If Not MobjWordapp Is Nothing Then<BR> For Each obj In MobjWordapp.Documents<BR> obj.Close<BR> Next<BR> &#039; MobjWordDocument.Close<BR> Set MRange = Nothing<BR> MobjWordapp.Quit<BR> Set MobjWordDocument = Nothing<BR> Set MobjWordapp = Nothing<BR> <BR>End If<BR><BR>End Sub<BR>Private Sub CreateWordObject()<BR> &#039;Test if object is already created before calling CreateObject:<BR> If TypeName(MobjWordapp) &#060;&#062; "Application" Then<BR> Set MobjWordapp = CreateObject("Word.Application")<BR> MobjWordapp.Visible = False<BR> End If<BR>End Sub<BR><BR>*************************************** *********<BR><BR>code written in form<BR><BR>Private Sub Command1_Click()<BR>Dim cls As New ClsWordEdit<BR><BR>cls.FileName = "c:1.doc"<BR> cls.Action OPENFILE<BR>cls.InsertAtStart "first"<BR>cls.InsertAtEnd "first"<BR>cls.Action SAVEFILEAS, "c:2.doc"<BR>Set cls = Nothing<BR>MsgBox ("done")<BR>End Sub<BR><BR>******************<BR>It works fine but<BR>when same thing is done through asp it is not working.<BR><BR>&#060;%<BR><BR>path = Request.ServerVariables("APPL_PHYSICAL_PATH") & "1.doc"<BR>tempfilepath = Request.ServerVariables("APPL_PHYSICAL_PATH") & "2.doc"<BR>strInit = " start "<BR>strLast = " end "<BR><BR> Dim objWordEdit<BR> set objWordEdit=server.CreateObject("CSLWORD.ClsWordEd it")<BR> objWordEdit.FileName = path<BR> objWordEdit.Action 4<BR> objWordEdit.InsertAtStart strInit<BR> objWordEdit.InsertAtEnd strLast<BR> objWordEdit.Action 2, tempfilepath<BR> Set objWordEdit = Nothing <BR>%&#062;<BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: word editing is working in VB but not in ASP

    When you execute it in VB, does it pop up any questions to the user?<BR><BR>Do you get any errors? You don&#039;t say.<BR><BR>Craig.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts