您的位置:程序门 -> vb -> vba



vba下如何生成另存为对话框


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


vba下如何生成另存为对话框[无满意答案结贴]
发表于:2007-08-30 07:32:14 楼主
问问大家

因为不是做office下面的vba应用,是一个工程软件的,希望得到一点意见.问题背景就是,我写了一个程序转换原来的文件格式并输出,现在程序只具备事先订好的路径,并不能自由选择.

能不能在vba环境下,生成一个另存为对话框,简单点说就是点击一个窗口按钮,能弹出一个对话框,能选择路径保存,   也能更改文件名字,文件格式我只需要一个,不需要多重选择

希望高手能给个方向.谢谢

发表于:2007-08-30 08:28:501楼 得分:0
declare   function   mygetsavefilename   lib   "comdlg32.dll "   alias   "getsavefilenamea "   (ofil   as   ces_openfilename)   as   integer

type   ces_openfilename
          lstructsize   as   long
          hwndowner   as   long
          hinstance   as   long
          lpstrfilter   as   string
          lpstrcustomfilter   as   string
          nmaxcustfilter   as   string
          nfilterindex   as   long
          lpstrfile   as   string
          nmaxfile   as   long
          lpstrfiletitle   as   string
          nmaxfiletitle   as   long
          lpstrinitialdir   as   string
          lpstrtitle   as   string
          flags   as   long
          nfileoffset   as   integer
          nfileextension   as   integer
          lpstrdefext   as   string
          lcustdata   as   long
          lpfnhook   as   long
          lptemplatename   as   string
end   type

dim   cmdlg_openfilename   as   ces_openfilename,   lngapiresults   as   long

        cmdlg_openfilename.lstructsize   =   len(cmdlg_openfilename)
        cmdlg_openfilename.hwndowner   =   frog_getactivewindow()

        lngapiresults   =   mygetsavefilename(cmdlg_openfilename)
发表于:2007-08-30 08:33:052楼 得分:0
在vba环境下?
用:activeworkbook.saveas   application.dialogs(xldialogsaveas).show
发表于:2007-09-01 11:04:053楼 得分:0
引用组件microsoft   common   dialog   control   6.0对应文件comdlg32.ocx
然后就很方便了,随时可以调用
发表于:2007-09-01 11:10:174楼 得分:0
拖动组件栏的commondialog到窗体就有一个commondialog1然后放上一个command1如下
private   sub   command1_click()
commondialog1.flags   =   &h401
commondialog1.showsave
msgbox   "你选择的文件是: "   &   commondialog1.filename
end   sub
发表于:2007-09-07 23:34:025楼 得分:0
谢谢大家,其实要的是一个树状的保存文档的对话框,commondialog解决不了问题,后来自己找到了api。


快速检索

最新资讯
热门点击