Problem writing to two Text boxs in Excel vb2010.net

Paul_Hairy

New member
Joined
Nov 26, 2011
Messages
1
Programming Experience
5-10
Hi all,
I have created an application that prompts me on a day by day basis and stores the information in an sql database.
The program can then generate time sheets expense sheets and work reports. Most of the application works however the problem I am having is with the report writing functions.

On my development PC which is running windows 7 ultimate and Excel 2007 there no problems however on my works laptop witch is running windows XP v2002 sp3 and Excel 2003 sp3

The report sheet contains two text boxes Text box 2 for the report and Text Box 3 for the site address.

When I compile the report on me development laptop it populates both the address box and the report box however when I compile the report on me work laptop it only populates the address box.

Bellow is my code.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Open specific Excel document
Dim oExcel As Object = CreateObject("Excel.Application")
Dim oBook As Object = oExcel.Workbooks.Open(ReportPath)
Dim oSheet As Object = oBook.Worksheets(1)
Dim ans As Single
Dim ErrorString As String = Nothing
' Read particular Cell
Dim ExcelFile As String

If SpellChecked = False Then
ans = MsgBox("Do you want to run a spell check", vbYesNo)
If ans = vbYes Then Call SpellAndGrammarCheck(MainForm.Note)
End If
regKey = Registry.LocalMachine.OpenSubKey("Software\TimeApp", True)

Xpath = regKey.GetValue("ExcelPath")
Dirpath = regKey.GetValue("DirPath")
UserName = regKey.GetValue("UserName")
regKey.Close()

oSheet.Range("B8").Value = TextBox2.Text
oSheet.Range("E8").Value = TextBox3.Text
oSheet.Range("E12").Value = TextBox5.Text
oSheet.Range("E10").Value = TextBox4.Text
oSheet.Range("E14").Value = TextBox6.Text
oSheet.Range("B52").Value = TextBox8.Text
oSheet.Range("D52").Value = TextBox9.Text

oSheet.TextBoxes("Text Box 2").Text = TextBox7.Text ' This line is not working
oSheet.TextBoxes("Text Box 3").Text = Address(JobNameIndex)

If Xpath = Nothing And Dirpath = Nothing Then ErrorString = ErrorString + " Excel executable file & Output Folder " : GoTo ovr
If Xpath = Nothing Then ErrorString = ErrorString + " Excel executable file "
If Dirpath = Nothing Then ErrorString = ErrorString + " Outpot folder "
ovr:
If ErrorString <> Nothing Then
If MainForm.CheckBox1.Checked = True Then MsgBox("Please select the Path to your " + ErrorString + "using the options menu")
MainForm.CheckBox1.Checked = False
End If


ExcelFile = Dirpath + "\Reports\"+ JobNameToSaveData(Trim(MainForm.JobNam.Text)) + "_Report_" + DateToSaveData(SelectedDate) + ".xls"
oBook.SaveAs(ExcelFile, True)
oExcel.Quit()
Shell(Xpath & " " & ExcelFile, vbMaximizedFocus)
End Sub

Any help would be much appreciated.

Thanks
Regards Paul.
 
Back
Top