提示用户打开另一个工作簿 [英] Prompt User to open another workbook

查看:49
本文介绍了提示用户打开另一个工作簿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个子程序,需要用户打开特定的工作簿,因为我需要将要打开的工作簿中的数据复制到运行该子程序的工作簿中.由于将要打开的文件是月度报告,因此用户很难始终将其保存在具有相同文件名的相同位置.因此,如果要求用户打开工作簿(月度报告),那就太好了.

I am writing a sub, where I need the user to open a specific workbook, because I need to copy data from the workbook that will be opened, to the workbook that is running the sub. Since the file that will be opened is a monthly report, it is difficult for the user to always save it in the same location with the same file name. Therefore it would be great if the user is asked to open the workbook (monthly report).

推荐答案

Function openMontlyReport() as Workbook
   MsgBox "Please select the monthly report in the next file dialog"
   With Application.FileDialog(msoFileDialogOpen)
     .Title = "Select Monthly Report"
     .Filters.Add "Excel Files", "*.*"
     .AllowMultiSelect = False
     If .Show Then Set openMontlyReport = Application.Workbooks.Open .SelectedItems(1)
   End With
End Function

现在您已经拥有了用户刚刚打开的每月工作簿.

Now you have at hand the monthly workbook that the user just opened.

这篇关于提示用户打开另一个工作簿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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