سؤال

لدي ما يلي الذي يفتح مربع الحوار سافاس ، ومع ذلك فإنه ليس في الواقع حفظ الملف عند النقر فوق حفظ.

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

With SaveBox
.AllowMultiSelect = False
.InitialFileName = "WeeklyLog " & Format(Now, "yyyy_mm_dd")
SaveBox.Show
End With
هل كانت مفيدة؟

المحلول

"...يفتح مربع الحوار سافاس ، ومع ذلك فإنه ليس في الواقع حفظ الملف عند النقر فوق حفظ"

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:

giveacodicetagpre.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top