Of the following 2 PowerPoint VBA codes, the first works for me but the
second, a shade more ambitious in trying the .Goto method, doesn't.
Can anyone tell why? What is holding up the .Goto? Are there any holes
in MS Office "interoperability"?
'mySlideShow.ppt Slide1
Option Base 1
Option Explicit
Private Sub CommandButton1_Click()
Dim ExcelApp As Object, ExcelwBook1 As Object, ExcelwBook2 As Object,
WBook2 As String, MySheet3 As Object
Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.Visible = True
WBook2 =
"D:\Projects\Housing\HousingInflation\ResamplingForUnbiasedTimeSeriesReg\
ression\MyProtoFolder\MyWorkbook2.xls"
ExcelApp.Workbooks.Open (WBook2)
ExcelApp.Workbooks(1).Sheets(3).Activate
Stop
ExcelApp.Workbooks(1).Close SaveChanges:=False
ExcelApp.Quit
Set ExcelApp = Nothing
End Sub
Private Sub CommandButton5_Click() 'Cross-Check
'On optionally clicking, displays for a few preview seconds the Slope
Variability vs. Autocorrelation graph of moloTables&Graphs.xls
Dim ExcelApp As Object, ExcelwBook As Object, wBook As String, wSheet As
Object, Start As Single
Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.Visible = True
wBook =
"D:\moloBackgroundPackageForDriveD\Mishmash\moloTables&Graphs.xls"
ExcelApp.Workbooks.Open (wBook)
ExcelApp.ActiveWorkbook.Sheets("MethodsCompare2B").Activate
Stop 'how make PowerPoint interpreter accept the following Excel VBA?
'ExcelApp.Goto Reference:=Range("A62:Q96"), Scroll:=True ' "Sub or
function not defined"
'Range("I77").Select 'desired cursor resting position
Start = Timer
Do While Timer < Start + 2 'Allow 2 seconds of preview dwell
time
'and return to Slide 1 automatically
DoEvents ' Yield to other processes.
Loop
ExcelApp.Workbooks(1).Close SaveChanges:=False
ExcelApp.Quit
Set ExcelApp = Nothing
End Sub
[Non-text portions of this message have been removed]
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.
----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA
----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com
----------------------------------
Tidak ada komentar:
Posting Komentar