문제

SaveAs 대화 상자가 열리지 만 저장을 클릭하면 실제로 파일을 저장하지 않습니다.

Dim SaveBox As Object
Set SaveBox = Application.FileDialog(msoFileDialogSaveAs)

With SaveBox
.AllowMultiSelect = False
.InitialFileName = "WeeklyLog " & Format(Now, "yyyy_mm_dd")
SaveBox.Show
End With
.

도움이 되었습니까?

해결책

"... SaveAseAs 대화 상자를 엽니 다. 그러나 저장을 클릭 할 때 실제로 파일을 저장하지 않습니다."

FileDialog는 파일 경로가 포함 된 문자열을 제공 할 수 있습니다.그러나 "다른 이름으로 저장"작업을 실제로 수행하지는 않습니다.개발자는 해당 파일 경로를 사용하여 어딘가에 무언가를 저장합니다.

Dim SaveBox As Object
Dim strFilePath As String

Set SaveBox = Application.FileDialog(2) ' msoFileDialogSaveAs
With SaveBox
    .InitialFileName = "WeeklyLog " & Format(Date, "yyyy_mm_dd")
    If .Show = True Then
        strFilePath = .SelectedItems(1)
    End If
End With

' now do something with strFilePath ...
If Len(strFilePath) > 0 Then
    MsgBox "File path: " & strFilePath
Else
    MsgBox "Selection cancelled."
End If
.

다른 팁

이렇게하면 Excel 파일을 저장하면 PDF를 저장할 수있는 조정이 작은 조정이 필요하다고 생각합니다.

Sub GetFileName()
    Dim fd As FileDialog
    Dim fname As String

    Do
        Set fd = Application.FileDialog(msoFileDialogSaveAs)
        With fd
            .AllowMultiSelect = False
            .InitialFileName = "New To Do.xls"
            If .Show = -1 Then fname = .SelectedItems(1)

            If fname = fd.InitialFileName Then _
                MsgBox "Please enter a new filename", vbOKOnly, "Filename Needed!"
        End With
    Loop Until fname <> fd.InitialFileName

    If IsEmpty(fname) Or fname = vbNullString Then Exit Sub
    ThisWorkbook.SaveAs fname

End Sub
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top