Discussion Locked

Visual Basic

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am writing my first VB Program and I need some help. I have several text boxes on the form and need to save the entire form to an excell spreadsheet. I have the menu save sub done, but it will only save one of the text boxes. Any help would be appreciated. The code looks like this...

Private Sub mnuFileSaveAs_Click()
CommonDialog1.Filter = "Excel Files (*.xls) | *.xls"
CommonDialog1.ShowSave
If CommonDialog1.FileName <> "" Then
Open CommonDialog1.FileName For Output As #1
Print #1, txtDate.Text
Close #1
End If

End Sub

3 replies

by fromnaija

Of course, you are only saving the content of txtDate, from your code! There are various ways of doing this. One way is to loop through all the textboxes and save the contents to the file as you are doing above. Another method is to automate Excel, open an Excel workbook, write the values of your textboxes to a worksheet and use Excel to save the file.
If you need sample code, you may contact me.

Regards.

This discussion is closed to new replies.