PDA

View Full Version : excel file saving issues



syed_iqbal
02-11-2017, 06:21 PM
hi,



I written VBA code in my project. but now i need to add some more lines regarding folder options.

while running code, first, macro should ask "choose main folder". Then automatically subfolder should create with the name "today's date" (Ex: 12-Feb-2017) in main folder. we need to assign the total path (drive,main folder and subfolder) to any string variable. if main folder drive is "C:\" or any external device then macro should not accept.

Thank you in advance for helping me.

regards
syed

mana
02-11-2017, 10:15 PM
Option Explicit


Sub test()
Dim myFolder As String


With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Plesse choose the folder"
If Not .Show Then Exit Sub
myFolder = .SelectedItems(1) & "\" & Format(Date, "d-mmm-yyyy")
End With

If Dir(myFolder, vbDirectory) = "" Then MkDir myFolder


End Sub

syed_iqbal
02-12-2017, 04:00 AM
hi,

thanks for reply. i'm sorry to say, you missed some points which i mentioned in my query. Pls share complete code including all conditions/saving restrictions.

syed_iqbal
02-12-2017, 04:58 AM
pls ignore this blank post