Try the following:
Code:
--------------------
Dim wb As Workbook
Dim number As Integer
If Range("open").Value = False Then
Set wb = Workbooks.Open("temp.xls")
wb.Activate
Sheets(1).Range("isOpen").Value = True
number = Sheets(1).Range("num").Value
Sheets(1).Range("num").Value = number + 1
Sheets(1).Range("isOpen").Value = False
wb.Close saveChanges:=True
MsgBox number
Else
MsgBox "Workbook busy. Try again in a few seconds."
End If
--------------------
whe
* open is the name of a cell in the sheet where this macro will be
fun from.
so if this macro is run from a file abc.xls then this cell should be on
the ACTIVE sheet of abc.xls
* temp.xls is the file where you store your number. It is
recommended you use the full file path here.
* isOpen is the name given to a cell in temp.xls on sheet 1. the
default value of this cell should be 'false'.
* num is the name given to a cell in temp.xls on sheet 1. its where
the number you need is stored.
hope this helps.
--
schoujar
------------------------------------------------------------------------
schoujar's Profile:
http://www.excelforum.com/member.php...o&userid=26574
View this thread:
http://www.excelforum.com/showthread...hreadid=547237