【问题标题】:Managing links in Excel source workbooks when duplicating source files复制源文件时管理 Excel 源工作簿中的链接
【发布时间】:2018-07-12 09:00:14
【问题描述】:

我有三个文件:

Activefile - 我的代码存储和运行的地方

数据库文件 - 我的原始数据所在的位置(有很多保护)

Copyofdatabasefile - 是没有保护的副本

我有一个在 activefile 中运行的宏来更新 databasefile excel 文件,稍后在宏中,我在 databasefile 为了制作一个数据库文件的副本文件,我删除了一些功能,让人们无需对主数据库文件进行一些检查即可轻松访问数据。

保存数据库文件副本时,我的活动文件中的链接会更新以查看新的数据库文件副本文件。我不希望这种情况发生。

如何调整我的 excel 链接/代码以确保我的文件中的链接不会传输到 数据库文件副本

Saveas 宏选项目前是:

Databasefile.SaveAs filename:="\\somelocation\copyofdatabasefile.xlsx", FileFormat:=51, CreateBackup:=False

【问题讨论】:

    标签: database vba excel save


    【解决方案1】:

    使用Workbook.SaveCopyAs Method 应该可以。

    如果您的原始文件是 xlsx,请使用

    Databasefile.SaveCopyAs Filename:="\\somelocation\copyofdatabasefile.xlsx"
    

    请注意,它仅以与原始文件相同的文件格式保存!


    如果您的原始文件是 xlsm 使用

    如果您需要更改文件格式(例如从xlsmxlsx),您需要先以原始文件格式另存为副本,然后使用Workbooks.Open() 重新打开该副本,然后使用.SaveAs 以更改文件格式。

    Databasefile.SaveCopyAs Filename:="\\somelocation\copyofdatabasefile.xlsm" 'if original file was xlsm
    
    Dim wb As Workbook
    Set wb = Workbooks.Open("\\somelocation\copyofdatabasefile.xlsm")
    wb.SaveAs filename:="\\somelocation\copyofdatabasefile.xlsx", FileFormat:=51, CreateBackup:=False
    wb.Close False
    Kill "\\somelocation\copyofdatabasefile.xlsm" 'delete old format
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-25
      • 1970-01-01
      • 2023-01-28
      • 1970-01-01
      • 2013-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多