I am getting an Object Reference Not Set to Instance error when I try to run my code (see below). The offending line is marked by Imports Aspose.Word Imports System.Data Imports System.Data.OleDb Public Class GenerateReport Inherits System.Web.UI.Page Protected WithEvents saveTypeBtn As System.Web.UI.WebControls.RadioButtonList Protected WithEvents Label5 As System.Web.UI.WebControls.Label Protected WithEvents Label3 As System.Web.UI.WebControls.Label Protected WithEvents Label1 As System.Web.UI.WebControls.Label Protected WithEvents Label2 As System.Web.UI.WebControls.Label Protected WithEvents Label4 As System.Web.UI.WebControls.Label Protected WithEvents addressEdit As System.Web.UI.WebControls.TextBox Protected WithEvents address2Edit As System.Web.UI.WebControls.TextBox Protected WithEvents cityEdit As System.Web.UI.WebControls.TextBox Protected WithEvents companyEdit As System.Web.UI.WebControls.TextBox Protected WithEvents generateBtn As System.Web.UI.WebControls.Button Protected WithEvents fullNameEdit As System.Web.UI.WebControls.TextBox Dim TWPPConn As OleDbConnection Dim TWPPCommand As OleDbCommand Dim TWPPReader As OleDbDataReader Dim strConString As String Dim newssql As String Dim cover_title As String Dim cover_subtitle As String Dim cover_contents As String Dim cover_date As String Dim contents As String Dim executivesummary As String Dim scope As String Dim keyfindings As String Dim recommendations As String Dim graphs As String Dim datatables As String Dim table_name_cover As String Dim table_name_contents As String Dim table_name_executivesummary As String Dim table_name_recommendations As String Dim table_name_keyfindings As String Dim table_name_scope As String Dim table_name_graphs As String Dim table_name_datatables As String Dim client As String Dim questionnaire As String Dim reportid As String #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here client = Request(“clientid”) questionnaire = Request(“questionnaire”) reportid = Request(“reportid”) table_name_cover = client & “" & questionnaire & "” & reportid & “reportcover" table_name_contents = client & "
table_name_executivesummary = client & "” & questionnaire & "” & reportid & “reportexecutivesummary"
table_name_recommendations = client & "” & questionnaire & “" & reportid & “reportrecommendations"
table_name_keyfindings = client & "” & questionnaire & "” & reportid & “reportkeyfindings"
table_name_scope = client & "” & questionnaire & “" & reportid & “reportscope"
table_name_graphs = client & "” & questionnaire & "” & reportid & “_reportgraphs”
TWPPConn = New OleDbConnection(“Provider=Microsoft.Jet.OLEDB.4.0;data source=” & Server.MapPath("…/data/twpp.mdb"))
TWPPConn.Open()
strConString = "Select * from " & table_name_cover
TWPPCommand = New OleDbCommand(strConString, TWPPConn)
TWPPReader = TWPPCommand.ExecuteReader(CommandBehavior.SingleRow)
If TWPPReader.Read() Then
If Not IsDBNull(TWPPReader(“title”)) Then
cover_title = TWPPReader(“title”)
End If
If Not IsDBNull(TWPPReader(“subtitle”)) Then
cover_subtitle = TWPPReader(“subtitle”)
End If
If Not IsDBNull(TWPPReader(“contents”)) Then
cover_contents = TWPPReader(“contents”)
End If
If Not IsDBNull(TWPPReader(“report_date”)) Then
cover_date = TWPPReader(“report_date”)
End If
End If
TWPPReader.Close()
strConString = "Select * from " & table_name_contents
TWPPCommand = New OleDbCommand(strConString, TWPPConn)
TWPPReader = TWPPCommand.ExecuteReader(CommandBehavior.SingleRow)
If TWPPReader.Read() Then
If Not IsDBNull(TWPPReader(“contents”)) Then
contents = TWPPReader(“contents”)
End If
End If
TWPPReader.Close()
strConString = "Select * from " & table_name_executivesummary
TWPPCommand = New OleDbCommand(strConString, TWPPConn)
TWPPReader = TWPPCommand.ExecuteReader(CommandBehavior.SingleRow)
If TWPPReader.Read() Then
If Not IsDBNull(TWPPReader(“contents”)) Then
executivesummary = TWPPReader(“contents”)
End If
End If
TWPPReader.Close()
strConString = "Select * from " & table_name_recommendations
TWPPCommand = New OleDbCommand(strConString, TWPPConn)
TWPPReader = TWPPCommand.ExecuteReader(CommandBehavior.SingleRow)
If TWPPReader.Read() Then
If Not IsDBNull(TWPPReader(“contents”)) Then
recommendations = TWPPReader(“contents”)
End If
End If
TWPPReader.Close()
strConString = "Select * from " & table_name_keyfindings
TWPPCommand = New OleDbCommand(strConString, TWPPConn)
TWPPReader = TWPPCommand.ExecuteReader(CommandBehavior.SingleRow)
If TWPPReader.Read() Then
If Not IsDBNull(TWPPReader(“contents”)) Then
keyfindings = TWPPReader(“contents”)
End If
End If
TWPPReader.Close()
strConString = "Select * from " & table_name_scope
TWPPCommand = New OleDbCommand(strConString, TWPPConn)
TWPPReader = TWPPCommand.ExecuteReader(CommandBehavior.SingleRow)
If TWPPReader.Read() Then
If Not IsDBNull(TWPPReader(“contents”)) Then
scope = TWPPReader(“contents”)
End If
End If
TWPPReader.Close()
strConString = "Select * from " & table_name_graphs
TWPPCommand = New OleDbCommand(strConString, TWPPConn)
TWPPReader = TWPPCommand.ExecuteReader(CommandBehavior.SingleRow)
If TWPPReader.Read() Then
If Not IsDBNull(TWPPReader(“contents”)) Then
graphs = TWPPReader(“contents”)
End If
End If
TWPPReader.Close()
' LICENSING
'If you don’t specify a license, an evaluation license is used by default.
'To use a proper license, uncomment code below and specify name of the license file.
Dim licenseFile As String = MapPath(“License”) + “\Aspose.Word.lic”
Aspose.Word.Word.SetLicense(licenseFile, Me)
'Open precreated designer file.
Dim word As Word = New Word
Dim doc As Document = New Document(MapPath(".") + “\Templates\report_template.doc”)
'Fill the fields in the document with user data.
doc.MailMerge.Execute( _
New String() {“CoverTitle”, “CoverSubTitle”, “CoverContents”, “CoverDate”, “Contents”, “ExecutiveSummary”, “Scope”, “KeyFindings”, “Recommendations”, “Graphs”}, _
New Object() {cover_title, cover_subtitle, cover_contents, cover_date, contents, executivesummary, scope, keyfindings, recommendations, graphs})
'Send the document in Word format to the client browser.
***doc.Save(“test.doc”, SaveFormat.FormatDocument, IIf(saveTypeBtn.SelectedIndex = 0, SaveType.OpenInBrowser, SaveType.OpenInWord), Me.Response)
End Sub
End Class