Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 17th, 2005, 03:26 AM
Registered User
 
Join Date: Jan 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Newbie Question - Launching Word

Hi,

I get the feeling this is a dumb question, but I am trying to run a mailmerge with word from an ASP.NET (VB) web page. I have created a text file that holds the merge data and I have a master document located on the local drive of the user (the text file is saved there as well).

As I am just setting out I am using Web Matrix as development environment. Also I am not splitting out the vb into a code behind page at the moment. It's all contained in the .aspx file.

When I load the page using the Web Matrix web server it works fine. The text file is created and Word launches and does the mail merge. If, however I launch the page using IIS, all works ok, except I can't get word to display. I have looked at task manager and the ASP.NET user has launched a Word process, the two files (.txt and .doc) are locked, but Word is not displayed.

Can anyone help? I have the code below:

==== CODE START ====

<%@ Page Language="VB" %>
<%@ import Namespace="System.IO" %>
<%@ import Namespace="System" %>

<script runat="server">

    Sub Page_Load(Sender As Object, E As EventArgs)

    End Sub

    Sub Button1_Click(sender As Object, e As EventArgs)

    Dim strData As String

    strData = "FirstName,Surname,Address,City,County,PostCod e" & vbCrLf
    strData = StrData & "Andy,Parker,93 Bushy Hill Drive,Guildford,Surrey,GU1 2UG" & vbCrLf
    strData = StrData & "Allison,Goody,7 Smith Road,Guildford,Surrey,GU4 4QY" & vbCrLf
    strData = StrData & "John,Smith,45 Red Road,Guildford,,GU4 4QY"

    Dim ExportFileName As string
    Dim MasterDocName As String

    ExportFileNAme = "C:\TDD\Templates\Andy.txt"
    MasterDocName = "C:\TDD\Templates\Test.doc"

    If File.Exists(ExportFileName) Then

        File.Delete(ExportFileName)

    End If

    Dim objStreamWriter As StreamWriter
    objStreamWriter = File.AppendText(ExportFileName)
    objStreamWriter.WriteLine(strData)
    objStreamWriter.Close

    Dim objWord As Object
    Dim objDoc As Object
    objWord = CreateObject("Word.Application")
    objDoc = objWord.Documents.Open(MasterDocName)
    objWord.Visible = True

    With objWord.ActiveDocument.MailMerge
         .OpenDataSource(ExportFileName)
         .SuppressBlankLines = True
         .Execute
    End With

    End Sub

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <p>
            <asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Create Label"></asp:Button>
        </p>
    </form>
</body>
</html>

==== CODE END ====

Thanks

Andy






Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie: Word -> XML jockster XML 0 March 18th, 2006 08:00 AM
Access launching Word for mail merge Loralee Access 8 November 14th, 2005 04:24 PM
newbie question Warbird XML 0 May 11th, 2005 08:41 AM
ASP launching exe question - URGENT! Rammek Classic ASP Basics 2 October 26th, 2004 05:30 PM
Launching an MS-Word template with user input form fpollari Classic ASP Basics 0 June 17th, 2003 09:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.