Outlook 2002 Save

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have written some code which gets data from a web site and converts if to
appointments in calendar.
I have also added a toolbar and button to do this in a click.
Some data is stored in a user form which I would like to be saved
automatically when I quit outlook so that it is there when I run Outlook
again.
Any ideas?

Thanks
 
Hi Pierre,

what do you mean by "data is stored in a user form"? Is your problem to
determine when or where the data should be stored?

For the timing I would maybe use the Form_Unload or Form_Terminate
event. Depending on the kind and size of data there are a lot of places
you can store to, e.g. a simple text file, or the registry.
 
Hi

Thanks for your reply.

The data I store in the form is Name Surname and a couple of other things.

I opted to use a form because:
a} It was the first thing that I thought of,
b) I would like to keep it all within Outlook to facilitate transfer to
other PC's

In any case, I am open to ideas.

How would I save the data to a text file?

Thanks again.

Pierre
 
Hi Pierre,

sample for reading/writing files:

Private Function ReadFile(sPath As String) As String
On Error GoTo AUSGANG
Dim lFileNr As Long
Dim sText As String

lFileNr = FreeFile

Open sPath For Binary As #lFileNr
sText = Space$(LOF(lFileNr))
Get #lFileNr, , sText

AUSGANG:
If lFileNr Then
Close #lFileNr
End If

If Err.Number Then Err.Raise &H800A0000 Or Err.Number, _
Err.Source, Err.Description, Err.HelpFile, Err.HelpContext

ReadFile = sText
End Function

Private Sub WriteFile(sPath As String, _
sText As String, _
Optional ByVal bAppend As Boolean _
)
On Error GoTo AUSGANG
Dim lFileNr As Long

lFileNr = FreeFile

Select Case bAppend
Case False
Open sPath For Output As #lFileNr
Case Else
Open sPath For Append As #lFileNr
End Select

Print #lFileNr, sText;

AUSGANG:
If lFileNr Then
Close #lFileNr
End If

If Err.Number Then Err.Raise &H800A0000 Or Err.Number, _
Err.Source, Err.Description, Err.HelpFile, Err.HelpConsText
End Sub
 
Back
Top