Hello. Background:
I am trying to write some PowerPoint VBA to fiddle with Excel objects embedded in my slides.
I have a slide, on which a (very small view of) an Excel Worksheet is embedded. As a matter of fact, the entire Workbook is embedded. I've managed to do ALMOST everything I want to do. I have a correct reference that WORKS:
dim wb as Workbook, ws as Worksheet
set wb = [blah blah, code that fetches the workbook from the slide]
set ws = wb.ActiveSheet
after running this code. ws is "nothing." I assume this is because the excel workbook is not actually Activated (workbook.windows.count returns 0).
I want ws to be the sheet which is VISIBLE in the ppt slide. assume there are 10 sheets in the workbook, and I am trying to delete all but the visible one. Is there some other code? i.e. wb.SELECTEDsheet or wb.VISIBLEsheet or something? obviously, neither of those exist.
I have tried the following, with identical results. i still get ws=nothing:
dim wb as Workbook, ws as Worksheet
set wb = [blah blah, code that fetches the workbook from the slide]
wb.activate
set ws = wb.ActiveSheet
can anyone help me out with a way to get a reference to the "visible" sheet? i would RATHER not have to "Activate" or open some Excel Application instance, or crap like that, but I'm desperate so will accept any hack. The reason I don't feel I should need to do these things is that I know i can do all sorts of other manipulations to the spreadsheets without having to do this.
Thank you in advance. The actual code follows.
Sub foo(s As Slide)
Dim x As Shape, y As Workbook
set x = s.shapes(1)
Set y = x.OLEFormat.Object
msgbox y.activesheet.name 'fails
end sub
I am trying to write some PowerPoint VBA to fiddle with Excel objects embedded in my slides.
I have a slide, on which a (very small view of) an Excel Worksheet is embedded. As a matter of fact, the entire Workbook is embedded. I've managed to do ALMOST everything I want to do. I have a correct reference that WORKS:
dim wb as Workbook, ws as Worksheet
set wb = [blah blah, code that fetches the workbook from the slide]
set ws = wb.ActiveSheet
after running this code. ws is "nothing." I assume this is because the excel workbook is not actually Activated (workbook.windows.count returns 0).
I want ws to be the sheet which is VISIBLE in the ppt slide. assume there are 10 sheets in the workbook, and I am trying to delete all but the visible one. Is there some other code? i.e. wb.SELECTEDsheet or wb.VISIBLEsheet or something? obviously, neither of those exist.
I have tried the following, with identical results. i still get ws=nothing:
dim wb as Workbook, ws as Worksheet
set wb = [blah blah, code that fetches the workbook from the slide]
wb.activate
set ws = wb.ActiveSheet
can anyone help me out with a way to get a reference to the "visible" sheet? i would RATHER not have to "Activate" or open some Excel Application instance, or crap like that, but I'm desperate so will accept any hack. The reason I don't feel I should need to do these things is that I know i can do all sorts of other manipulations to the spreadsheets without having to do this.
Thank you in advance. The actual code follows.
Sub foo(s As Slide)
Dim x As Shape, y As Workbook
set x = s.shapes(1)
Set y = x.OLEFormat.Object
msgbox y.activesheet.name 'fails
end sub