View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
KermanPM KermanPM is offline
external usenet poster
 
Posts: 1
Default Reading File and adding contents to spreadsheet

I need to read a number (counter) from a file (.txt probably), and add it to
my spreadsheet. Then increment that number by one, and store the result back
into the file. The purpose is so different users can open the spreadsheet
and get the next available number to number the form. Here's how I did it in
Word. How do I do it in Excel?

Public Sub MAIN()
Dim CheckNum$
Dim docnum$
CheckNum$ = WordBasic.[GetFormResult$]("DocNumField")
If CheckNum$ = "00000" Then
docnum$ = WordBasic.[GetPrivateProfileString$]("DocTracker", "DocNum", _
"U:\Counter\TemplateCounter.INI")
docnum$ = Str((WordBasic.Val(docnum$) + 1))
WordBasic.SetFormResult "DocNumField", docnum$
WordBasic.SetPrivateProfileString "DocTracker", "DocNum", docnum$, _
"U:\Counter\TemplateCounter.INI"
ActiveWindow.ActivePane.HorizontalPercentScrolled = 34
End If
End Sub