Automatically save a file on a network drive

Cablek

Board Regular
Joined
Nov 22, 2017
Messages
51
I want to have a button in a workbook that will allow me to save a file name from values in C3 and D3 + add the date and save it to a network drive (eg. o:\customer drawings\ "value B3" \)

so to resume 1 I need to check to see if the folder exists, if not create it from value B3... then same file using C3+D3 + DATE

I have a partial code for C3 and D3 but not the folder name and it's also giving me an error

Private Sub CommandButton1_Click()
Dim Path As String
Dim Filename1 As String
Dim Filename2 As String
Path = "o:\Customer Drawings"
Filename1 = Range("C3")
Filename2 = Range("D3")
ActiveWorkbook.SaveAs Filename:=Path & Filename1 & "-" & Filename2 & ".xlsx", FileFormat:=xlNornal
End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
How about
Code:
Private Sub CommandButton1_Click()
Dim Pth As String
Dim Filename1 As String
Dim Filename2 As String
Pth = "C:\Users\DaveC\Desktop\test\" & Range("B3").Value
Filename1 = Range("C3").Value
Filename2 = Range("D3").Value
If Dir(Pth, vbDirectory) = "" Then MkDir (Pth)
ActiveWorkbook.SaveAs FileName:=Pth & "\" & Filename1 & "-" & Filename2 & Format(Date, "dd-mm-yyyy") & ".xlsx", FileFormat:=51
End Sub
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,351
Messages
6,124,445
Members
449,160
Latest member
nikijon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top