AlyNeedsHelp
02-03-2022, 11:22 AM
I am very new to this, but I am attempting to try to have a 'submit button' in my survey, in word, to save to a specific file per submission.
The company I work for is trying to go paperless to some extent and I have been set to figure it out.
Each employee signs in on a sheet each day for covid, among other documents for other reasons.
I have so far gotten my code to allow me to have it save directly to a file, but it overwrites every time a new form is submitted.
How do I get this to stop?
I have pasted my code below to hopefully see where I've gone wrong.
Sub CommandButton1_Click()
Dim strNewFolderName As String
strNewFolderName = "Covid Sheets " & (Day(Now) & " " & Month(Now())) & " " & Year(Now)
If Len(Dir("Q:\Vault\Shop Forms\Covid Sheets" & strNewFolderName, vbDirectory)) = 0 Then
MkDir ("Q:\Vault\Shop Forms\Covid Sheets" & strNewFolderName)
End If
Dim PathName As String
PathName = ("Covid Sheets " & MonthName(Month(Now())) & " " & Year(Now))
ActiveDocument.SaveAs FileName:="Q:\Vault\Shop Forms\Covid Sheets" & strNewFolderName & "" & Split(ActiveDocument.Name, "")(0) & ".doc", _
FileFormat:=wdFormatDocument
End Sub
The company I work for is trying to go paperless to some extent and I have been set to figure it out.
Each employee signs in on a sheet each day for covid, among other documents for other reasons.
I have so far gotten my code to allow me to have it save directly to a file, but it overwrites every time a new form is submitted.
How do I get this to stop?
I have pasted my code below to hopefully see where I've gone wrong.
Sub CommandButton1_Click()
Dim strNewFolderName As String
strNewFolderName = "Covid Sheets " & (Day(Now) & " " & Month(Now())) & " " & Year(Now)
If Len(Dir("Q:\Vault\Shop Forms\Covid Sheets" & strNewFolderName, vbDirectory)) = 0 Then
MkDir ("Q:\Vault\Shop Forms\Covid Sheets" & strNewFolderName)
End If
Dim PathName As String
PathName = ("Covid Sheets " & MonthName(Month(Now())) & " " & Year(Now))
ActiveDocument.SaveAs FileName:="Q:\Vault\Shop Forms\Covid Sheets" & strNewFolderName & "" & Split(ActiveDocument.Name, "")(0) & ".doc", _
FileFormat:=wdFormatDocument
End Sub