在 Mac 上使用 excel 2016 按钮打开 word 文档 [英] open word doc with excel 2016 button on mac

查看:74
本文介绍了在 Mac 上使用 excel 2016 按钮打开 word 文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用此代码和按钮在运行 high sierra 的 Mac 上的 excel 2106 中打开 word 文档:

I am trying to use this code with a button to open a word doc in excel 2106 on a mac running high sierra:

Sub buttontest1()
Dim objdoc As Object

FileName = "/Volumes/256SSD/word docs/shortcut keys.docx"

With CreateObject("word.application")

Set objdoc = .documents.open(FileName)
End With

Set objdoc = Nothing
End Sub

我第一次运行它时,它运行良好.然后我关闭 word doc(命令 q)并再次运行它,但出现运行时错误-2146959355 (80080005)并打开一个空白的 word 文档.我在运行时错误框中单击结束"并退出单词 doc 并再次运行代码,单词 doc 正确打开.我退出文档并再次运行并得到运行时错误.

The first time I run this, it works fine. I then close the word doc (command q) and run it again but I get a runtime error -2146959355 (80080005) and a blank word doc opens. I click "End" in the runtime error box and quit the word doc and run the code again and the word doc opens correctly. I quit the doc and run again and get the run time error.

有人可以帮忙吗?

PS 我曾尝试在文件路径中使用 : 代替/但这会产生不同的错误

PS I have tried using : instead of / in the file path but that gives a different error

推荐答案

我可以重现该行为.这似乎是 Mac VBA 的一个已知问题 - 一年多以来,微软证实:

I can reproduce the behaviour. This appears to be a known issue with Mac VBA - since more than a year, as confirmed by Microsoft:

https://answers.microsoft.com/en-us/msoffice/forum/msoffice_officeinsider-mso_mac-msoinsider_excel/trying-to-open-word-from-excel-vba-results-in-run/856d9a54-cc92-4ad8-9f49-cae38e7335b7

这篇关于在 Mac 上使用 excel 2016 按钮打开 word 文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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