访问VBA和Excel自动化无法正常工作。 [英] Access VBA and Excel Automation not working.

查看:100
本文介绍了访问VBA和Excel自动化无法正常工作。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些运行Access应用程序的PC,除了一台机器外,一切都运行良好。 "好"的机器具有适用用户要求的各种软件配置。大多数都运行Windows 7和Office 365.
所有都是最新的。一台机器是一台64位机器,运行的是Office 365和MS Excel 2010.该应用程序在这台机器上运行正常。 "坏"机器具有相同的设置,但它是一台32位机器。在32位计算机上,Excel Automation失败。
有问题的代码如下:


'用于引用Excel和对象的变量

Dim MySheetPath As String

Dim xl作为Excel.Application

Dim XlBook As Excel.Workbook

Dim XlSheet As Excel.Worksheet

    

'告诉它实际Excel文件的位置

MySheetPath = strFileSource



设置XlBook = GetObject(MySheetPath)     '这是在32位计算机上失败的线路。

   

'确保屏幕上显示excel

XlBook.Windows(1).Visible = True

 

'将工作簿中的工作表定义为XlSheet

设置XlSheet = XlBook.Worksheets(1)


任意关于如何解决问题的想法?卸载Excel 2010不是一个选项,因为它对公司所依赖的其他软件至关重要。


Thanx。

解决方案

< blockquote>我认为你需要通过识别问题来帮助我们。你收到错误了吗?如果是这样,它是什么?


I have a number of pc's running an Access Application and everything works perfectly except on one machine. The "good" machines have various software configurations as required by the applicable user. Most are running Windows 7 and Office 365. All are up to date. One machine is a 64 bit machine and is running Office 365 and MS Excel 2010. The App works just fine on this machine. The "bad" machine has the same setup but its a 32 bit machine. On the 32 bit machine the Excel Automation fails. The code in question is as follows:

'Variables to refer to Excel and Objects
Dim MySheetPath As String
Dim xl As Excel.Application
Dim XlBook As Excel.Workbook
Dim XlSheet As Excel.Worksheet
    
' Tell it location of actual Excel file
MySheetPath = strFileSource

Set XlBook = GetObject(MySheetPath)      'This is the line that fails on the 32 bit machine.
   
'Make sure excel is visible on the screen
XlBook.Windows(1).Visible = True
 
'Define the sheet in the Workbook as XlSheet
Set XlSheet = XlBook.Worksheets(1)

Any ideas on how to fix the problem? Uninstalling Excel 2010 is not an option because its essential for other software the company relies on.

Thanx.

解决方案

I think you need help us out a bit by identifying the problem. Are you getting an error? If so, what is it?


这篇关于访问VBA和Excel自动化无法正常工作。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆