这是我另存为的代码: 
Private   Sub   menuSaveAS_Click() 
On   Error   GoTo   errorlab   '出错调至行标签errlab 
CommonDialog1.FileName   =   "文本1.txt "   '设置缺省文件名 
CommonDialog1.DefaultExt   =   "txt "   '设置缺省扩展名 
CommonDialog1.InitDir   =   "d:\ "   '初始化路径 
CommonDialog1.Filter   =   "Word   文档(*.doc) ¦*.doc ¦文本文件(*.txt) ¦*.txt ¦所有文件(*.*) ¦*.* " 
CommonDialog1.FilterIndex   =   1 
CommonDialog1.CancelError   =   True 
CommonDialog1.ShowSave 
Open   savefilename   For   Output   As   #1 
Print   #1,   Text1.Text 
Close   #1 
errorlab: 
End   Sub 
这个代码就是你一点它,就是都会弹出保存对话框, 
而保存要求的是第一次点它是会出现保存对话框,而已经保存过后,你再点保存时,则不会弹出保存对话框 
我的保存代码是这样: 
Private   Sub   menuSave_Click() 
If   savefilename   <>   " "   Then 
Open   savefilename   For   Output   As   #1 
Print   #1,   Text1.Text 
Close   #1 
Else 
Call   menuSaveAS_Click 
End   If 
End   Sub 其中把savefilename   设为全局变量,并且savefilename=commondialog1.filename当保存过时,savefilename 
不为空,如果为空,则没保存 

解决方案 »

  1.   

    不知道你的savefilename怎么来的,根本没有附值呀
    加个
    savefilename=CommonDialog1.filename
      

  2.   

    刚刚看掉你最后一句话了:P你说你附值了,可没看你程序不知道你附值正确不,你可以Private       Sub       menuSave_Click()
    '加这么一句,看看savefilename的值正确不,然后查找原因
    msgbox savefilename 
    exit sub
    '结束   
    If       savefilename       <>       "   "       Then   
    Open       savefilename       For       Output       As       #1   
    Print       #1,       Text1.Text   
    Close       #1   
    Else   
    Call       menuSaveAS_Click   
    End       If   
    End       Sub   
      

  3.   

    应该加在CommonDialog1.ShowSave下面才正确。
      

  4.   

    改了点,试了没有问题
    Private savefilename As String
    Private Sub menuSaveAS_Click()
    On Error GoTo errorlab                         '出错调至行标签errlab
    CommonDialog1.FileName = "文本1.txt   "                   '设置缺省文件名
    CommonDialog1.DefaultExt = "txt   "                   '设置缺省扩展名
    CommonDialog1.InitDir = "d:\   "                   '初始化路径
    CommonDialog1.Filter = "Word文档(*.doc)|*.doc|文本文件(*.txt)|*.txt|所有文件(*.*)|*.*"
    CommonDialog1.FilterIndex = 1
    CommonDialog1.CancelError = True
    CommonDialog1.ShowSave
    savefilename = CommonDialog1.FileName
    Open savefilename For Output As #1
    Print #1, Text1.Text
    Close #1
    errorlab:
    End SubPrivate Sub menuSave_Click()
    If savefilename <> "" Then
    Open savefilename For Output As #1
    Print #1, Text1.Text
    Close #1
    Else
    Call menuSaveAS_Click
    End If
    End SubPrivate Sub Command1_Click()
    menuSave_Click
    End Sub
    Private Sub Command2_Click()
    menuSaveAS_Click
    End Sub
      

  5.   

    savefilename = CommonDialog1.FileName之后得判断是否有返回值