如何使用powerpoint在VBA前台打开excel
我试图在powerpoint演示文稿中打开excel文件。 这是我的代码:如何使用powerpoint在VBA前台打开excel,excel,vba,powerpoint,Excel,Vba,Powerpoint,我试图在powerpoint演示文稿中打开excel文件。 这是我的代码: Sub diversestickersKoole() Dim xlApp As Object Dim xlWorkBook As Object Set xlApp = CreateObject("Excel.Application") xlApp.Visible = True Set xlWorkBook = xlApp.Workbooks.Open("V:\Oliedocs\Koole\Stickers Sche
Sub diversestickersKoole()
Dim xlApp As Object
Dim xlWorkBook As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlWorkBook = xlApp.Workbooks.Open("V:\Oliedocs\Koole\Stickers Scheepstanks Koole.xltm", True, False)
Set xlApp = Nothing
Set xlWorkBook = Nothing
End Sub
excel文件正在后台打开。这一定是在前台
有人能帮我吗?添加行xlWorkBook.Activate就足够了 您的代码应该如下所示:
Sub diversestickersKoole()
Dim xlApp As Object
Dim xlWorkBook As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlWorkBook = xlApp.Workbooks.Open("V:\Oliedocs\Koole\Stickers Scheepstanks Koole.xltm", True, False)
xlWorkBook.Activate
Set xlApp = Nothing
Set xlWorkBook = Nothing
End Function
供参考:
发布第4行,添加第xl行工作簿。激活应该足够了 您的代码应该如下所示:
Sub diversestickersKoole()
Dim xlApp As Object
Dim xlWorkBook As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlWorkBook = xlApp.Workbooks.Open("V:\Oliedocs\Koole\Stickers Scheepstanks Koole.xltm", True, False)
xlWorkBook.Activate
Set xlApp = Nothing
Set xlWorkBook = Nothing
End Function
供参考:
Post#4您可以使用
AppActivate
下面的代码使用“test.xlsx-Excel”,因为这是我的测试工作簿的标题
贴纸SCHEPSTANKS Koole.xltm-Excel应该适合您
Sub diversestickersKoole()
Dim xlApp As Object
Dim xlWorkBook As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
'Set xlWorkBook = xlApp.Workbooks.Open("V:\Oliedocs\Koole\Stickers Scheepstanks Koole.xltm", True, False)
Set xlWorkBook = xlApp.Workbooks.Open("C:\temp\test.xlsx", True, False)
AppActivate "test.xlsx - Excel"
Set xlApp = Nothing
Set xlWorkBook = Nothing
End Sub
您可以使用
AppActivate
下面的代码使用“test.xlsx-Excel”,因为这是我的测试工作簿的标题
贴纸SCHEPSTANKS Koole.xltm-Excel应该适合您
Sub diversestickersKoole()
Dim xlApp As Object
Dim xlWorkBook As Object
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
'Set xlWorkBook = xlApp.Workbooks.Open("V:\Oliedocs\Koole\Stickers Scheepstanks Koole.xltm", True, False)
Set xlWorkBook = xlApp.Workbooks.Open("C:\temp\test.xlsx", True, False)
AppActivate "test.xlsx - Excel"
Set xlApp = Nothing
Set xlWorkBook = Nothing
End Sub
由于您似乎对保留Excel对象及其派生对象不感兴趣,您可能希望编写如下代码
Sub diversestickersKoole()
With CreateObject("Excel.Application") '<--| create a new Excel instance and reference it (all its derived objects will be reached by a 'dot')
.Visible = True
.WindowState = -4137 '<--| maximize Excel window
.Workbooks.Open("V:\Oliedocs\Koole\Stickers Scheepstanks Koole.xltm", True, False).Activate
End With
End Sub
Sub-diversestickersKoole()
使用CreateObject(“Excel.Application”)”因为您似乎对保留Excel对象及其派生对象不感兴趣,所以您可能需要编写如下代码
Sub diversestickersKoole()
With CreateObject("Excel.Application") '<--| create a new Excel instance and reference it (all its derived objects will be reached by a 'dot')
.Visible = True
.WindowState = -4137 '<--| maximize Excel window
.Workbooks.Open("V:\Oliedocs\Koole\Stickers Scheepstanks Koole.xltm", True, False).Activate
End With
End Sub
Sub-diversestickersKoole()
使用CreateObject(“Excel.Application”)“它不应该是End子函数而不是End函数吗?代码将在演示文稿顶部打开工作簿。问题是什么?它不应该是End Sub而不是End Function吗?代码将在演示文稿顶部打开工作簿。问题是什么?很遗憾,这不起作用,excel文件是在后台打开的。很遗憾,这不起作用,excel文件是在后台打开的。