Ok guys I have a excel spread sheet that creates a value in Cell A1. It also disables the save and save as function. I now want to do a few other things.
I want a submit button that will do the following:
1. Create file in \\servername\folder\valueincellA1.xls
2. This file should then be saved to disable the macro the creates that value in A1. I don't want the value in A1 Changing once this new file is created.
3. The submit button should also bring up outlook and auto populate subject "SSR has been created" and the body should contain unc path to file and its name.
4. The submit button should continue function through itslife because it may be changed and emailed serveral times. Here is a clip of the code I have so far.
Option Explicit
Private Sub Workbook_Open()
Dim x As String
On Error GoTo ErrorHandler
One:
Open "\\servername\sharename\Forms\" & ThisWorkbook.Name & _
" Counter.txt" For Input As #1
Input #1, x
Close #1
x = x + 1
Two:
'******THIS LINE IS OPTIONAL******
Sheets(1).Range("A1").Value = x
'********************************
Open "\\servername\sharename\Forms\" & ThisWorkbook.Name & _
" Counter.txt" For Output As #1
Write #1, x
Close #1
Exit Sub
ErrorHandler:
Select Case Err.Number
Case 53 'If Counter file does not exist...
NumberRequired:
x = InputBox("Enter a Number greater than " & _
"zero to Begin Counting With", _
"Create '\\servername\sharename\Forms\" & ThisWorkbook.Name & _
" Counter.txt' File")
If Not IsNumeric(x) Then GoTo NumberRequired
If x <= 0 Then GoTo NumberRequired
Resume Two
Case Else
Resume Next
End Select
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
MsgBox "Save is Disabled"
' Following line will prevent all saving
Cancel = True
' Following line will prevent the Save As Dialog box from showing
If SaveAsUI Then SaveAsUI = False
End Sub
Bookmarks