Windows文件打开/保存常用对话框 [英] Windows File Open / Save Common Dialogues

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

问题描述

我使用这个Access Cookbook来自Ken Getz,它附带了一些非常好的示例代码和应用程​​序。


我使用了一些文件打开的功能,但我不知道他们创造了什么只使用我想要的部分。


我正在尝试使用Windows文件打开类型对话框来识别目录,然后将该目录作为字符串返回到最终的函数处理该文件中的所有excel电子表格,并选择要附加到我的Access数据库中的表格的特定数据。


我似乎要沿着两条路径之一走下去...要么使用FileDialog对象或Windows API直接。我只是不知道我需要做什么才能把目录归还给我。


提前感谢您的帮助!

I use this "Access Cookbook" from Ken Getz that comes with some pretty nice sample code and applications.

I use some file open features they have but I don''t know enough about what they''ve created to use just the parts I want.

I''m trying to use the Windows File Open type dialogue to identify a directory and then return that directory as a string to a function that will ultimately process all the excel spreadsheets in that file and select specific data to append to a table in my Access DB.

I seem to be going down one of 2 paths... either using the FileDialog object or the Windows API drectly. I just don''t know what I need to do to get the directory returned to me.

Thanks in advance for any help!

推荐答案

我假设您正在使用文件对话框让用户识别其特定文件所在的目录?


您可以发布文件对话框代码吗现在正在使用?


基本上你最终会设置一个Variant数据类型变量来保存从用户选择返回的.SelectedItems。然后你可以像测量任何字符串变量那样测试这个变量。


问候,

Scott
I assume that you are using the File Dialog in order to have a user identify the directory where their particular files reside?

Could you post the File Dialog code you are using now?

Basically you''ll end up setting a Variant datatype variable to hold the .SelectedItems returned from the user selection. You can then test this variable as you would any string variable.

Regards,
Scott



我假设您使用文件对话框让用户识别其特定文件所在的目录?


您可以发布文件您现在使用的对话框代码?


基本上你最终会设置一个Variant数据类型变量来保存从用户选择返回的.SelectedItems。然后你可以像测量任何字符串变量一样测试这个变量。


问候,

Scott
I assume that you are using the File Dialog in order to have a user identify the directory where their particular files reside?

Could you post the File Dialog code you are using now?

Basically you''ll end up setting a Variant datatype variable to hold the .SelectedItems returned from the user selection. You can then test this variable as you would any string variable.

Regards,
Scott



谢谢斯科特!这是代码。

表单上有一个click on click,它调用一个函数,该函数又调用下面的另一个函数

Thanks Scott! Here''s the code.

The form has this on click sub that calls a function which in turn calls another function below

展开 | 选择 | Wrap | 行号


首先,一如既往,但特别是在发布该数量的代码时,请使用提供的[code]标签!这里没有人会花时间浏览超过130行代码而至少没有代码标签提供的额外帮助。它们易于使用:只需选择代码文本,然后单击此窗口顶部的#图标。然后,您可以手动编辑VBA的第一个标记:[code = vb]。这里的所有都是它的!谢谢。


其次,您的代码返回一个已包含所选文件路径的变量。这被称为strResult。在您发布的最后一个函数中。您只需要拆分字符串变量,查找最后一个''\''标记,以定义路径结束的位置和文件名的开头。


我正在出门,但会回复给你说明如何找到strResult变量的路径部分。


问候,

Scott
First of all, as always, but especially when posting that amount of code please use the [code] tags provided! No-one here will take the time to wade through over 130 lines of code without at least the added help the code tags give. They are simple to use: Simply select the code text, then click the # icon on the top of this window. You can then manually edit the first tag to look like this for VBA: [code=vb]. That''s all there is to it! Thanks.

Secondly, your code returns a variable already containing the chosen file path. This is called "strResult" in the last function that you posted. You will simply need to split the string variable looking for the last ''\'' mark to define where the path ends and the file name begins.

I''m on my way out the door but will get back to you with instructions on how to find the path portion of the strResult variable.

Regards,
Scott


这篇关于Windows文件打开/保存常用对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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