J'essaie d'afficher où un file est enregistré dans une boîte de message avec le code suivant:
Sub export() Dim MyPath As Ssortingng Dim MyFileName As Ssortingng MyFileName = "MyFileName" Worksheets("Tab").Copy With Application.FileDialog(msoFileDialogFolderPicker) .Title = "Select a Folder" .AllowMultiSelect = False .InitialFileName = "Path" If .Show = -1 Then GoTo Nextcode1 Else GoTo Nextcode2 End If MyPath = .SelectedItems(1) & "\" End With Nextcode1: Block of codes that deals with existing file name. GoTo Nextcode3 Nextcode2: Block of codes that deals with cancel. GoTo Nextcode4 NextCode3: Application.DisplayAlerts = False With ActiveWorkbook .SaveAs fileName:=MyPath & MyFileName, FileFormat:=xlCSV, CreateBackup:=False .Close False End With Application.DisplayAlerts = True Worksheets("OtherTab").Activate MsgBox ("The tab has been exported to " & MyPath & MyFileName & ".") GoTo NextCode4 NextCode4: End Sub
Toutefois, la boîte de message ne s'affiche que
The tab has been exported to MyFileName.
Avec MyPath complètement omis. J'ai essayé les codes suivants
PathName = MyPath & MyFileName MsgBox ("The tab has been exported to " & PathName & ".")
Et
Cstr(MyPath) MsgBox ("The tab has been exported to " & MyPath & MyFileName & ".")
En vain. Ma suspicion est que le nom du path d'access obtenu à partir de msoFileDialogFolderPicker
n'est pas un object de string, mais je ne suis pas sûr de savoir comment y faire face. L'aide est appréciée!
Ok, ma mauvaise. le
MyPath = .SelectedItems(1) & "\"
la ligne devrait être passée
If .Show = -1 Then