INTELLIGENT WORK FORUMS FOR COMPUTER PROFESSIONALS
Come Join Us!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- One-Click Access To Your
Favorite Forums
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site

(Download This Button Today!)
Member Feedback
"...I am so glad that I found your site, it is an excellent resource and has helped me greatly..."
Geography
Where in the world do Tek-Tips members come from?
|
Copying cells from excel spreadsheet to axspreadsheet
|
|
|
fawkes (TechnicalUser) |
16 Sep 04 10:31 |
I'm creating an application where I intend to add an axspreadsheet object (excel office web component) to my form.
We have a number of excel spreadsheets that various people create and maintain but I want to make them accessible with added functionality gained by a bespoke application.
What I want to do is copy the contents of a spreadsheet, formulae, values, etc. from the excel spreadsheet object to the axspreadsheet object.
I can run a loop to add the contents of each cell in the excel spreadsheet to the respecive cell in the axspreadsheet and I can start the copy procedure in the excel spreadsheet then manually select the cell in the axspreadsheet and, using the paste command from the pop-up menu, paste the contents into the axspreadsheet.
So how do I perform the paste using code?
Any ideas? |
|
|
fawkes (TechnicalUser) |
17 Sep 04 3:40 |
|
|
fawkes (TechnicalUser) |
17 Sep 04 3:48 |
What a plank!! My code wasn't complete enough. This works CODE 'Declare new excel and worksheet objects Dim objExcel As New Excel.ApplicationClass Dim objSheet As Excel.Worksheet Try 'Create and open the correct excel workbook objExcel = CreateObject("Excel.Application") objExcel.Workbooks.Open("C:\Book1.xls") objExcel.Visible = True objExcel.Parent.Windows(1).Visible = True Catch ex As Exception MessageBox.Show(ex.Message) End Try
'Select all the cells in the relevant worksheet 'and copy the contents objSheet = objExcel.ActiveSheet objSheet.Cells.Select() objSheet.Cells.Copy()
'Select a cell in the AxSpreadsheet control that is 'already declared and initialised in the class Me.AxSpreadsheet1.Cells(2, 2).Select()
'Paste the contents Me.AxSpreadsheet1.Cells(2, 2).Paste()
Taking a fresh look in the morning certainly helps. Fawkes |
|
|
fawkes (TechnicalUser) |
17 Sep 04 3:53 |
I've hit a secondary problem. I've added the following code to the end: CODE objExcel.Quit() objExcel = Nothing GC.Collect() The problem is that I keep getting a message asking if I want to save data on the clipboard, how do I stop this? |
|
|
fawkes (TechnicalUser) |
17 Sep 04 5:49 |
I've found another couple of problems with my method.
1. It doesn't copy any objects (images, etc.) 2. It doesn't copy cell properties like protection or column width.
Any ideas on this at all? |
|
I cant see where you have saved the sheet in your code but if you have you need to add the line :objsheet.saved = true before your :objexcel.quit line
What reference have you added? |
|
|
 |
|