用VB保存excel [英] Saving excel with VB

查看:181
本文介绍了用VB保存excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个java代码填充我的XLSM文件上的数据,问题是,java代码无法处理宏的执行,所以我我只是用java填充excel文件,然后打开excel并手动保存,然后调用宏。


我想自动执行,所以我创建了一个VB脚本,它将打开文件并将保存它,但问题是,即使它保存并关闭文件,似乎它没有调用宏。


@edit:


当我点击保存(Ctrl + S)或单击关闭按钮并保存时执行宏。


关于如何做到这一点的任何想法?我是Visual Basic的新手。

展开 | 选择 | Wrap | 行号

解决方案

开始在开放一个excelfile的宏:

把它放在工作簿代码中:

展开 | 选择 | Wrap | 行号





感谢您的回复,但在阅读您的回复并知道通过呼叫来调用宏时;方法,我搜索了所有Microsoft Excel对象/工作表代码单词Call一无所获。我现在不知道宏或只是VBA方法是负责填写我的Excel工作表上的一些列的人。如果它只是VBA方法,是否有一个方法或关键字在你按下Ctrl + S时会做出反应。或保存并退出按钮?


@edit:我在代码Workbook_beforeSave()上找到了一个方法,我将其复制并更改为Workbook_Open() ;。现在,每次打开文档时,它都会运行填充某些列的宏/方法。现在我正在尝试将其转换为宏,这样我就可以调用宏来填充一些列。


我认为我的下一个任务,我想我需要追加/添加一个特定的功能(比如复制Workbook_beforeSave()的内容并创建具有相同功能的Workbook_Open() excel文件,它仍然会像我以前的excel一样运行。这可以通过VB脚本实现吗?



谢谢。


< blockquote>这将打开Excel,运行宏,保存文件并关闭工作簿。

展开 | 选择 | Wrap < span class =codeDivider> | 行号


Hi,

I have a java code that populates data on my XLSM file, the problem is, the java code can''t handle the execution of Macro, so what I''m just doing is to populate the excel file with java and then open the excel and save it manually and then the macro will be invoked.

I wanted to do it automatically, so I created a VB script that will open the file and will save it as well but the problem is, even though it saves and closes the file, it seems that it didn''t invoked the Macro.

@edit:

The macro is executed the moment I hit save (Ctrl + S) or when I click the close button and save.

Any ideas on how can I do this? I''m just new with Visual Basic.

Expand|Select|Wrap|Line Numbers

解决方案

To start a macro at the opening of an excelfile:
put this in the workbook code:

Expand|Select|Wrap|Line Numbers


Hi,

Thanks for the reply but after reading your reply and knowing that invoking a Macro is by means of "Call" method, I have searched all the "Microsoft Excel Objects/Worksheet codes" for a word "Call" and found nothing. I don''t know now if the Macro or just the VBA method is the one responsible for filling out some of the columns on my excel sheet. if it''s just the VBA method, is there a method or keyword that reacts when you''re pressing the "Ctrl + S" or "Save and Exit" button?


@edit: I have found a method on the code "Workbook_beforeSave()", I copied it and changed it to "Workbook_Open()". and now, everytime I open the document, it runs the Macro/Method that fills some of the columns. And now I''m trying to convert it into a Macro so that I will just call on the Macro to do the filling of some columns.

I think for my next task, I think I need to append/add a certain function(like copying the content of Workbook_beforeSave() and create Workbook_Open() with the same function on an excel file so that it will still behave the same way like my previous excel. Is this attainable through VB Script?


Thanks.


This will open Excel, run the macro, save the file and close the workbook.

Expand|Select|Wrap|Line Numbers


这篇关于用VB保存excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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