Display an Excel Spreadsheet in a VBA Form

pellacad

New Member
Joined
Apr 21, 2002
Messages
9
How would I go about "loading" an existing Excel spreadsheet in to my VBA form...

I've figured out how to copy cells to an Excel control form...but I want to show all the cell formatting, column width and colors of the original Excel file.

I want to give my users the ability to view, manipulate and save the Excel data from within a VBA form.

Thanks! (code follows...)

Private Sub CommandButton29_Click()
Dim excelapp As excel.Application
Dim wbkObj As Workbook
Dim shtObj As Worksheet
On Error Resume Next
Err.Clear
Set excelapp = GetObject(, "Excel.Application")
Set shtObj = excelapp.Worksheets(1)
ivai% = 1
rvai& = 1.5
sval$ = "text"

shtObj.Cells(1, 1) = ivaf%
shtObj.Cells(2, 1) = rval&
shtObj.Cells(3, 1) = sval$
MainEditor2.Show
Debug.Print (CurrentRowNumber)
Spreadsheet1.Rows(CurrentRowNumber).Insert
Spreadsheet1.Cells(CurrentRowNumber, 1) = Mid(MainEditor0.tbKeyNoteNumber.Text, 1, 2)
Spreadsheet1.Cells(CurrentRowNumber, 2) = MainEditor0.tbKeyNoteNumber.Text
Spreadsheet1.Cells(CurrentRowNumber, 4) = MainEditor0.tbCategoryName.Text
Spreadsheet1.Cells(CurrentRowNumber, 5) = MainEditor0.tbKeyNoteLabel.Text
Spreadsheet1.Cells(CurrentRowNumber, 3) = MainEditor0.tbCurrentNote.Text

End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,215,054
Messages
6,122,893
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top