Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default auto numbering

I am using a function that does autonumbering for a invoice using a *.txt file.

My problem is although i have spesified a default path for the txt file it
still safes it in the "my documents" folder and not the default path as
spesified in the code. I am using vista business and office 2007 pro.

here is the code


Public Function NextSeqNumberInv(Optional sFileNameInv As String, Optional
nSeqNumberInv As Long = -1) As Long

'invoice autonumbering
Const sDEFAULT_PATH As String = "C:\seqnum"
Const sDEFAULT_FNAME As String = "DefaultSeqInv.txt"
Dim nFileNumberInv As Long

nFileNumberInv = FreeFile
If sFileNameInv = "" Then sFileNameInv = sDEFAULT_FNAME
If InStr(sFileNameInv, Application.PathSeparator) = 0 Then _
sFileName = sDEFAULT_PATH & Application.PathSeparator &
sFileNameInv
If nSeqNumberInv = -1& Then
If Dir(sFileNameInv) < "" Then
Open sFileNameInv For Input As nFileNumberInv
Input #nFileNumberInv, nSeqNumberInv
nSeqNumberInv = nSeqNumberInv + 1&
Close nFileNumberInv
Else
nSeqNumberInv = 1&
End If
End If
On Error GoTo PathError
Open sFileNameInv For Output As nFileNumberInv
On Error GoTo 0
Print #nFileNumberInv, nSeqNumberInv
Close nFileNumberInv
NextSeqNumberInv = nSeqNumberInv
Exit Function
PathError:
NextSeqNumberInv = -1&
End Function

Pls help I don't know where am i goign wrong with this


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default auto numbering

use the CHDRIVE and CHDIR to repoint the system,

Const sDEFAULT_PATH As String = "C:\seqnum"
Const sDEFAULT_FNAME As String = "DefaultSeqInv.txt"
Dim nFileNumberInv As Long
CHDRIVE LEFT(sDEFAULT_PATH,2)
CHDIR sDEFAULT_PATH


"Oakleaf tech" wrote:

I am using a function that does autonumbering for a invoice using a *.txt file.

My problem is although i have spesified a default path for the txt file it
still safes it in the "my documents" folder and not the default path as
spesified in the code. I am using vista business and office 2007 pro.

here is the code


Public Function NextSeqNumberInv(Optional sFileNameInv As String, Optional
nSeqNumberInv As Long = -1) As Long

'invoice autonumbering
Const sDEFAULT_PATH As String = "C:\seqnum"
Const sDEFAULT_FNAME As String = "DefaultSeqInv.txt"
Dim nFileNumberInv As Long

nFileNumberInv = FreeFile
If sFileNameInv = "" Then sFileNameInv = sDEFAULT_FNAME
If InStr(sFileNameInv, Application.PathSeparator) = 0 Then _
sFileName = sDEFAULT_PATH & Application.PathSeparator &
sFileNameInv
If nSeqNumberInv = -1& Then
If Dir(sFileNameInv) < "" Then
Open sFileNameInv For Input As nFileNumberInv
Input #nFileNumberInv, nSeqNumberInv
nSeqNumberInv = nSeqNumberInv + 1&
Close nFileNumberInv
Else
nSeqNumberInv = 1&
End If
End If
On Error GoTo PathError
Open sFileNameInv For Output As nFileNumberInv
On Error GoTo 0
Print #nFileNumberInv, nSeqNumberInv
Close nFileNumberInv
NextSeqNumberInv = nSeqNumberInv
Exit Function
PathError:
NextSeqNumberInv = -1&
End Function

Pls help I don't know where am i goign wrong with this


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default auto numbering

That did the job

THx a million!!!

"Patrick Molloy" wrote:

use the CHDRIVE and CHDIR to repoint the system,

Const sDEFAULT_PATH As String = "C:\seqnum"
Const sDEFAULT_FNAME As String = "DefaultSeqInv.txt"
Dim nFileNumberInv As Long
CHDRIVE LEFT(sDEFAULT_PATH,2)
CHDIR sDEFAULT_PATH


"Oakleaf tech" wrote:

I am using a function that does autonumbering for a invoice using a *.txt file.

My problem is although i have spesified a default path for the txt file it
still safes it in the "my documents" folder and not the default path as
spesified in the code. I am using vista business and office 2007 pro.

here is the code


Public Function NextSeqNumberInv(Optional sFileNameInv As String, Optional
nSeqNumberInv As Long = -1) As Long

'invoice autonumbering
Const sDEFAULT_PATH As String = "C:\seqnum"
Const sDEFAULT_FNAME As String = "DefaultSeqInv.txt"
Dim nFileNumberInv As Long

nFileNumberInv = FreeFile
If sFileNameInv = "" Then sFileNameInv = sDEFAULT_FNAME
If InStr(sFileNameInv, Application.PathSeparator) = 0 Then _
sFileName = sDEFAULT_PATH & Application.PathSeparator &
sFileNameInv
If nSeqNumberInv = -1& Then
If Dir(sFileNameInv) < "" Then
Open sFileNameInv For Input As nFileNumberInv
Input #nFileNumberInv, nSeqNumberInv
nSeqNumberInv = nSeqNumberInv + 1&
Close nFileNumberInv
Else
nSeqNumberInv = 1&
End If
End If
On Error GoTo PathError
Open sFileNameInv For Output As nFileNumberInv
On Error GoTo 0
Print #nFileNumberInv, nSeqNumberInv
Close nFileNumberInv
NextSeqNumberInv = nSeqNumberInv
Exit Function
PathError:
NextSeqNumberInv = -1&
End Function

Pls help I don't know where am i goign wrong with this


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto numbering Adam Excel Programming 1 April 13th 09 10:07 AM
aUTO nUMBERING Udayan New Users to Excel 2 March 12th 09 10:07 AM
Auto Numbering Nigel 2000 Excel Discussion (Misc queries) 2 September 19th 06 09:34 AM
Auto Numbering Starguy Excel Worksheet Functions 0 March 26th 06 11:51 PM
Auto numbering Chong Moua Excel Programming 0 July 9th 03 04:04 PM


All times are GMT +1. The time now is 10:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"