命令到其他办公应用程序时

命令到其他办公应用程序时

本文介绍了当使用函数/命令到其他办公应用程序时,使VBE帮助器显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一些操作其他办公应用程序(办公室)的代码。当我写我的代码,我想让VBE帮助我的属性和功能就像链接到excel的那些。



这是怎么做到的?例如,当我输入word_doc并添加一个点后,我希望VBE给我下载选项。就像我将word_doc设置为打开一个excel文件一样。



word_doc - >设置word_doc = word_app.documents.Open(C:\Users\sjan\Desktop\MailingLetter.docx)

解决方案

您必须通过 早期绑定 Word应用程序获取Word提示在您的Excel VBA窗口。在 Excel VBE 中,转到工具|参考,向下滚动到 Microsoft Word xx.0对象库和点击复选框。然后,尝试这个代码。

  Sub testword()
'将对象声明为早期绑定的对象
Dim oWord As Word.Application
设置oWord = CreateObject(Word.Application)

带oWord
.Visible = True
停止
'~~~>在此行上方输入一个点以查看所有Word选项
End with
End Sub


I'm writing some code which manipulates other office applications ( office ). When I write my code I would like to have the VBE help me with the properties and functions just as it does for those linked to excel.

How is this done? E.g I would like the VBE to give me "bookmarks" as an drop-down alternative when i enter word_doc and add a dot after. Just like it does after I have the word_doc set to open an excel file.

word_doc --> Set word_doc = word_app.documents.Open("C:\Users\sjan\Desktop\MailingLetter.docx")

解决方案

You have to Early Bind the Word Application to get Word hints to work on your Excel VBA window. In the Excel VBE, Go to Tools|References and scroll down to Microsoft Word xx.0 Object Library and click the checkbox. Then, try this code.

Sub testword()
    ' Declare the object as a early-bound object
    Dim oWord As Word.Application
    Set oWord = CreateObject("Word.Application")

    With oWord
        .Visible = True
        Stop
    '~~~>Type a dot above this line to see all the Word choices
    End With
End Sub

这篇关于当使用函数/命令到其他办公应用程序时,使VBE帮助器显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 00:16