O Código:
Private Sub CommandButton1_Click()
Dim strTemp As String
On Error GoTo CommandButton1_Click_Error
Open "F:Gabineteteste.txt" For Input As #1
Line Input #1, strTemp
Range("A1").Value = strTemp + 1
Close #1
Open "F:Gabineteteste.txt" For Output As #1
strTemp = Range("A1").Value
Print #1, strTemp
Close #1
On Error GoTo 0
Exit Sub
CommandButton1_Click_Error:
MsgBox "Erro " & Err.Number & " (" & Err.Description & ") no procedimento CommandButton1_Click"
End Sub
EXCELer Tudo sobre EXCEL em Português

