在Access窗体上的未绑定对象框架中抓取嵌入式Excel工作表 [英] Grabbing the embedded excel sheet in an unbound object frame on an Access form

查看:193
本文介绍了在Access窗体上的未绑定对象框架中抓取嵌入式Excel工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在访问表单中的未绑定对象框架中使用嵌入式Excel工作表进行数据输入。 在大多数情况下,它适用于我需要它做的事情。 问题是大约25%的时间,我的代码没有正确抓取工作表。 
它会抓住错误的纸张,或者甚至找不到对象;它在尝试时或当我双击对象时出错,它会运行办公室设置(好像这实际上可以解决问题所在)。 我目前获取表单的代码是:

I am using an embedded excel sheet in an unbound object frame in an access form for data entry.  For the most part, it works for what I need it to do.  The problem is that about 25% of the time, my code isn't grabbing the sheet correctly.  Either it will grab the wrong sheet or it can't even find the object; it errors out when trying or when I double click the object, it runs office setup (as if that would actually fix whatever that problem is).  My current code for grabbing the sheet is:

Private Sub GrabWorksheet()

On Error GoTo Fail
set robj = RateSheet.Object.Application
objv = robj.Visible
RateSheet.Action = acOLEActivate
设置rwks = RateSheet.Object.Application.ActiveSheet
设置rwkb = rwks.Parent
设置robj = rwkb.Parent
robj.SendKeys" {esc}"
robj.Visible = objv
On Error GoTo 0
退出Sub
失败:
MsgBox"那不起作用,请再试一次"

On Error GoTo Fail Set robj = RateSheet.Object.Application objv = robj.Visible RateSheet.Action = acOLEActivate Set rwks = RateSheet.Object.Application.ActiveSheet Set rwkb = rwks.Parent Set robj = rwkb.Parent robj.SendKeys "{esc}" robj.Visible = objv On Error GoTo 0 Exit Sub Fail: MsgBox "That didn't work, please try again"

End Sub

通常,当我运行它时,它会打开excel窗口,并将对象显示为已禁用。 每次打开表单时获得更可靠/更清晰的方法和/或创建新Excel实例的方法都会有所帮助。

Often, when I run that, it leaves the excel window open and shows the object as if it is disabled.  Any help on getting a more reliable/cleaner method and/or a way to create a new instance of excel each time the form opens would be most helpful.

谢谢。

Cassandra Morphy

Cassandra Morphy

推荐答案


它运行办公室设置(好像这实际上会修复无论那个问题是什么)。

it runs office setup (as if that would actually fix whatever that problem is).


听起来你的PC上可能有多个版本的Access,或者是Outlook或Visio的不同版本的Access。是这种情况吗?

Sounds like you may have more than one version of Access on your PC or a different version of Access then either Outlook or Visio. Is this the case?


这篇关于在Access窗体上的未绑定对象框架中抓取嵌入式Excel工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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