我需要通过visual basic 6在Excel上播放宏 [英] i need to play macro on Excel by visual basic 6

查看:73
本文介绍了我需要通过visual basic 6在Excel上播放宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我需要在Excel bay visual basic 6上播放宏

I need to play macro on Excel bay visual basic 6


并打开我的file.xlsb因为打开我的VBA App

and open my file.xlsb because open my VBA App


-此应用程序在Windows中的Excel工作簿之后打开双击点击 

-this app open after excel workbook in windows a duple click 


-my办公室是2007

-my office is 2007

推荐答案

你必须使用Excel自动化n:

You have to use Excel Automation:

        Dim oExcel As Object
        Dim oBook As Object
        Dim oBooks As Object

        'Start Excel and open the workbook.
        Set oExcel = CreateObject("Excel.Application")
        oExcel.Visible = True
        Set oBooks = oExcel.Workbooks
        Set oBook = oBooks.Open("C:\Users\username\Documents\WorkbookName.xlsx")

        'Run the macros.
        oExcel.Run "DoKbTest"
        oExcel.Run "DoKbTestWithParameter", "Hello from VB Client"

        'Clean-up: Close the workbook and quit Excel.
        oBook.Close SaveChanges:=False
        Set oBook = Nothing
        Set oBooks = Nothing
        oExcel.Quit
        Set oExcel = Nothing


这篇关于我需要通过visual basic 6在Excel上播放宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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