“另存为导出:”函数可以在导出之前选择命名文件。 [英] "Save As export:" function to have the option of naming the file before exporting.

查看:60
本文介绍了“另存为导出:”函数可以在导出之前选择命名文件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已启动并运行此代码以导出查询。现在,当我点击导出时按钮,它提示我要将文件导出到哪个文件夹。但它并没有要求我输入FILE NAME字样。或者换句话说,命名我将要导出的文件。因此,我应该在现有代码中添加什么来添加该选项呢?



到目前为止我的代码是:

I have this code up and running for exporting queries. Right now, when I click "EXPORT" button, it prompts me as to which folder I would like to have the file exported to. But it does not ask me to type in the "FILE NAME" or in other words, name the file that I will be exporting. Therefore, what should I be adding to my existing codes to add that option as well?



The codes I have so far is:

展开 | 选择 | Wrap | 行号

推荐答案

Michelle,对于许多选择ADezii代码的人来说,这将是一个好主意。但是,在您的理解水平上,我建议您更好地建议您从链接文章中获取代码。让我解释一下。


大多数人会看到这段代码并理解它为什么以及如何运作。当他们需要进行微小的修改(例如您在此处要求的修改)时,他们将使用代码并进行更改,这些修改相对简单。但是,在您理解的程度上,您需要为这些事情寻求帮助的地方,将一个编写为灵活的例程并在各种不同的场景中使用会更有意义(对于早期帖子中提到的文章 - 选择一个文件或使用FileDialog对象的文件夹)。这样,你需要了解的是如何调用这个程序。


让我看看我是否可以给你一些帮助来设置它:
Michelle, for many people choosing ADezii''s code to work with would be a great idea. At your level of understanding though, I suggest you''d be better advised taking the code from the linked article instead. Let me explain.

Most people would see this code and understand why and how it works. When they needed minor modifications such as what you ask for here, they would work with the code and make the changes, which are relatively straightforward. At your level of understanding though, where you need to ask for help for such things, it would make more sense to have a routine that is written to be flexible and to be used within various different scenarios (as is so for the code in the article referred to in the earlier thread - Select a File or Folder using the FileDialog Object). That way, all you need to understand is how to call this one procedure.

Let me see if I can give you some help setting this up :
  1. 从链接的文章中获取 FSBrowse()的代码,并将其放入项目的标准模块中。
  1. Grab the code for FSBrowse() from the linked article and put it into a standard module in your project.
  1. 在Access窗口中按Alt-F11切换到VBA IDE。
  2. 显示 Project Explorer 窗格(Ctrl-R)。
  3. 主项目下方最多有三个文件夹图标。最上面的一个将包含主要对象的模块(表单;报告;等)。在下面可能是一个名为 Modules 的文件。
  4. 如果存在,可能会有许多模块连接到它。您可以选择其中一个来添加代码或忽略这些代码,然后按照以下步骤添加代码。如果将代码添加到现有模块,请确保前两行位于其顶部。如果其中任何一个已经存在,则不需要重复。
  5. 要添加新模块,您是否需要或选择,将鼠标放在 Project Explorer 中窗格,右键单击并选择插入... ,然后选择模块
  6. 将之前抓取的代码粘贴到此处,替换已存在的任何内容。
  1. From your Access Window press Alt-F11 to switch to the VBA IDE.
  2. Show the Project Explorer pane (Ctrl-R).
  3. Underneath your main project are up to three folder icons. The top one will contain modules for your main objects (Forms; Reports; etc). Underneath that may be one called Modules if any exist.
  4. If this exists there may be a number of modules connected to it. You can either choose one of these to add the code into or ignore these and follow the steps below to add one instead. If you add the code to an existing module then ensure that the first two lines go at the very top of it. If either is already present then it won''t need to be duplicated.
  5. To add a new module, should you need or choose to, put the mouse inside the Project Explorer pane, right-click and select Insert... followed by Module.
  6. Paste the code you grabbed previously into here replacing anything already in there.

您现在有一个包含 FSBrowse()功能的项目。

  • 现在我们只需稍微操作您的代码即可使用此功能直接将其编码为ADezii的代码(这对于帮助更高级的编码人员更好地理解这个主题是个好消息,但对你来说却不那么好)。
  • 然后用以下代码替换你的代码:

    You now have a project which includes the FSBrowse() function.

  • Now we just need to manipulate your code a little to use this function instead of coding it directly as ADezii''s code did (which was good news for helping more advanced coders understand the subject better, but less so for you).
  • Replace your code then, with :

    展开 | 选择 | Wrap | 行号


    感谢NeoPa!我知道我对你和其他专家都很痛苦。我尽我所能尽可能地学习,因为我是Access的新手。


    无论如何,我试过你刚才说的话。我通过复制和粘贴创建了FSBrowse模块。


    然后我把代码放到导出按钮,它给了我错误。

    代码如下:

    Thanks NeoPa! I know I am such a pain to you and to the rest of the experts.. I am trying my best to learn as much as possible as I am very new to Access.


    Anyways, I tried what you just said. I created FSBrowse module by copy and paste.

    Then I put the code to the export button and it is giving me error.
    the codes are as follow:

    展开 | 选择 | Wrap | 行号


    这对我没有意义。为了清楚起见,你说的是编译时突出显示的代码是:
    That makes no sense to me. Just to be clear, you''re saying the code that''s highlighted when you compile it is :
    展开 | 选择 | Wrap | 行号


    这篇关于“另存为导出:”函数可以在导出之前选择命名文件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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