VBA共享工作簿和非共享工作簿 [英] VBA Shared workbook and Unshared workbook

查看:132
本文介绍了VBA共享工作簿和非共享工作簿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到共享工作簿的代码,并取消了与Visual Basic的共享,但是我没有找到它,有人知道它可能吗?

I tried to find the code to share workbook and unshared it with visual basic but I didn't find it, anyone know if its possible?

另一件事是共享工作簿保存后,将工作簿更新为所有用户...问题是如果我将其与可视化的基本代码一起保存,工作簿将更新为其他用户吗?

Another thing is shared workbooks when saved, update the workbook to all users... the question is if I save it with visual basic code the workbook will update to another users?

我正在编码一个单击该按钮的按钮(共享工作簿>填充单元格>保存并取消共享).

I am coding an button that when clicked it (share the workbook > fill the cells > save and unshared it).

推荐答案

我当然同意pnuts以及他提供的链接:共享工作簿太可怕了.

I certainly agree with pnuts and the link he provided: Shared Workbooks are horrible.

但是,为了回答这个问题,如果您在Excel中记录宏,则在共享工作簿时会看到类似以下的代码.

To respond to the question though, if you record a macro in Excel you will see code like the following when you share a workbook.

Sub Macro1()
    Workbooks.Add
    With ActiveWorkbook
        .KeepChangeHistory = True
        .ChangeHistoryDuration = 30
    End With
    ActiveWorkbook.SaveAs Filename:= _
        "F:\Documents and Settings\student\My Documents\Book1.xlsx", FileFormat:= _
        xlOpenXMLWorkbook, AccessMode:=xlShared
    ActiveWorkbook.ExclusiveAccess
End Sub

(如果您还不知道如何在Excel中记录宏,那么我建议您花些时间来查找-这非常有用,尤其是在您刚开始使用VBA时.)

(If you don't already know how to record a macro in Excel then I recommend that you take the time to find out - it is extremely useful, particularly when you are just starting with VBA.)

如果将此代码复制到VB编辑器中,然后单击某些单词(尤其是 SaveAs ),然后按F1键,您将进入帮助系统.

If you copy this code into the VB Editor and click on certain words (SaveAs in particular) and press F1 you will get into the Help system.

我从这个录制的宏中推测,从工作簿中删除共享只是将 SaveAs xlShared 以外的 AccessMode 一起使用的一种情况(或省略).毕竟,这是我们手动共享或取消共享工作簿时出现的对话框/选项.

From this recorded macro I surmise that removing Shared from a workbook is just a case of using SaveAs with an AccessMode other than xlShared (or omitted). After all, this is the dialog/option that appears when we manually share or un-share a workbook.

但是,要强调的是,我并不主张使用共享工作簿.

But, to emphasize, I am not advocating the use of Shared Workbooks.

这篇关于VBA共享工作簿和非共享工作簿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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