Rebam98
Computer
- Mar 28, 2006
- 14
Hi-
I'm working on something and cannot for the life of me figure out why it won't work.
I need to pull in a range of cells from Excel into powerpoint, to complete a presentation. This is the code I have. It's not complete because I have been stepping through the code until I get to the end, and it give me the generic '1004' application or object defined error.
The problem comes in selecting a range in Excel. I can get cell "A1," i.e. a single cell, just fine but when I try to define a larger range, it crashes. I've racked my brain for every possible thing I could do. I tried setting up a named range and referencing it (in the commented out code below) to no avail.
The code below is a little simpler than what I am doing, to isolate out the main problem. Basiclaly I just need to be able to pick out a range of cells in Excel from PowerPoint.
Please help.
sub get_excel_range()
Dim amberwrkbook As Excel.Workbook
Set amberwrkbook = GetObject("H:\Notes\Learning VBA\Making Summary to play with.xls")
amberwrkbook.Application.Sheets(24).Range("A1").Select '<-- works just fine
amberwrkbook.Application.Sheets(24).Range(Cells(1, 1), Cells(8, 8)).Copy '<-- CRASH, FAIL BURN!
'amberwrkbook.Application.Names.Add "Summary_Sheet", Range(Cells(1, 1), Cells(8, 8))
'amberwrkbook.Application.Sheets(24).Range("Summary_Sheet").Copy
......
End Sub
I'm working on something and cannot for the life of me figure out why it won't work.
I need to pull in a range of cells from Excel into powerpoint, to complete a presentation. This is the code I have. It's not complete because I have been stepping through the code until I get to the end, and it give me the generic '1004' application or object defined error.
The problem comes in selecting a range in Excel. I can get cell "A1," i.e. a single cell, just fine but when I try to define a larger range, it crashes. I've racked my brain for every possible thing I could do. I tried setting up a named range and referencing it (in the commented out code below) to no avail.
The code below is a little simpler than what I am doing, to isolate out the main problem. Basiclaly I just need to be able to pick out a range of cells in Excel from PowerPoint.
Please help.
sub get_excel_range()
Dim amberwrkbook As Excel.Workbook
Set amberwrkbook = GetObject("H:\Notes\Learning VBA\Making Summary to play with.xls")
amberwrkbook.Application.Sheets(24).Range("A1").Select '<-- works just fine
amberwrkbook.Application.Sheets(24).Range(Cells(1, 1), Cells(8, 8)).Copy '<-- CRASH, FAIL BURN!
'amberwrkbook.Application.Names.Add "Summary_Sheet", Range(Cells(1, 1), Cells(8, 8))
'amberwrkbook.Application.Sheets(24).Range("Summary_Sheet").Copy
......
End Sub