我在Excel 2010中創建了一個簡單的電子表格,其中包含一個在電子表格打開時加載的表單。員工填寫所需的表單數據並使用SaveAs方法按下「保存」按鈕宏。Excel VBA - 保存前禁用表單
我的問題是如果可以禁用保存的副本中的表單?原因是我想避免在我們的簿記部門打開副本審查數據時加載表單。
爲了澄清這是我的VBA代碼是如何
Sub SaveAsButton()
Dim applicationUserName As String
Dim saveLocation As String
Dim fileName As String
Dim weekNo As String
Dim year As String
weekNo = ThisWorkbook.Sheets("Service").Range("M4").Value
Debug.Print (weekNo)
year = ThisWorkbook.Sheets("Service").Range("R4").Value
Debug.Print (year)
applicationUserName = Application.UserName
Debug.Print (applicationUserName)
saveLocation = "w:\Service Users\" & applicationUserName & "\Service\"
Debug.Print (saveLocation)
fileName = "Service" & "-" & weekNo & "-" & year & "-" & applicationUserName
Debug.Print (fileName)
fileName = Replace(fileName, " ", "")
Debug.Print (fileName)
ThisWorkbook.SaveAs (saveLocation & fileName)
End Sub
謝謝。
這是最簡單的解決方案 - 謝謝! –