Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Problems with reading / writing ini-file

Hi,

I have an Excel workbook that uses an ini-file.

The principle I'm using is as follows:
There is a basic sheet that is used to create calculations. The user always
opens the basis sheet when creating new calculations. When opening this file,
it is checked whether a certain ini-file is present. If not the data for this
file has to be entered first (via a form that is called from the sheet). Some
things that are stored in this ini-file are the file location for storing the
calculations and a sequence number that is used for creating file-names for
the calculation.

When the user is ready with his calculation, the user presses a button in
the sheet. This will do the following: a unique name for the calculation is
created (using the seq. number from the ini-file); the calculation is save
using this name; the sequence number in the ini-file is increased).

For reading / writing the ini-file I use:
- getWindowsDirectory for determining the Windows directory
- WritePrivateProfileString/GetPrivateProfileString for writing and reading
the ini-file.

For quite some time this has worked without any problems. On most systems I
have it still works (i.e. XP Home SP2 with Excel 2003 SP2; XP Pro SP2 with
Excel 2000 SP3). However a user has a laptop (XP Pro SP2 + Excel 2003 SP2)
where these functions do not work!!
The function getWindowsDirectory returns no result and the functions
WritePrivateProfileString and GetPrivataProfileString do not work correctly.

Does anyone know (the cause of) this problem?
How could I solve this issue?

I'm looking for some general solution that will work on all the different
environments.

Thanx in advance
Youp


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Problems with reading / writing ini-file

Does your code look like

Dim sDir As String
Dim cLength As Long

sDir = Space(255)
cLength = GetSystemDirectory(sDir, 255)
sDir = Left(sDir, cLength)
Debug.Print "System directory path: "; sDir


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Youp" wrote in message
...
Hi,

I have an Excel workbook that uses an ini-file.

The principle I'm using is as follows:
There is a basic sheet that is used to create calculations. The user

always
opens the basis sheet when creating new calculations. When opening this

file,
it is checked whether a certain ini-file is present. If not the data for

this
file has to be entered first (via a form that is called from the sheet).

Some
things that are stored in this ini-file are the file location for storing

the
calculations and a sequence number that is used for creating file-names

for
the calculation.

When the user is ready with his calculation, the user presses a button in
the sheet. This will do the following: a unique name for the calculation

is
created (using the seq. number from the ini-file); the calculation is save
using this name; the sequence number in the ini-file is increased).

For reading / writing the ini-file I use:
- getWindowsDirectory for determining the Windows directory
- WritePrivateProfileString/GetPrivateProfileString for writing and

reading
the ini-file.

For quite some time this has worked without any problems. On most systems

I
have it still works (i.e. XP Home SP2 with Excel 2003 SP2; XP Pro SP2 with
Excel 2000 SP3). However a user has a laptop (XP Pro SP2 + Excel 2003 SP2)
where these functions do not work!!
The function getWindowsDirectory returns no result and the functions
WritePrivateProfileString and GetPrivataProfileString do not work

correctly.

Does anyone know (the cause of) this problem?
How could I solve this issue?

I'm looking for some general solution that will work on all the different
environments.

Thanx in advance
Youp




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Problems with reading / writing ini-file

Hi,

This is the code that I currently use:

lngx = apiGetWindowsDirectory(strIniFile, Len(strIniFile))
If lngx < 0 Then
GetIniFileName = Left(strIniFile, lngx) & "\" & "PTPT.ini"
Else
GetIniFileName = Empty
End If

So the principle is the same as in your example.

Youp


"Bob Phillips" wrote:

Does your code look like

Dim sDir As String
Dim cLength As Long

sDir = Space(255)
cLength = GetSystemDirectory(sDir, 255)
sDir = Left(sDir, cLength)
Debug.Print "System directory path: "; sDir


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Youp" wrote in message
...
Hi,

I have an Excel workbook that uses an ini-file.

The principle I'm using is as follows:
There is a basic sheet that is used to create calculations. The user

always
opens the basis sheet when creating new calculations. When opening this

file,
it is checked whether a certain ini-file is present. If not the data for

this
file has to be entered first (via a form that is called from the sheet).

Some
things that are stored in this ini-file are the file location for storing

the
calculations and a sequence number that is used for creating file-names

for
the calculation.

When the user is ready with his calculation, the user presses a button in
the sheet. This will do the following: a unique name for the calculation

is
created (using the seq. number from the ini-file); the calculation is save
using this name; the sequence number in the ini-file is increased).

For reading / writing the ini-file I use:
- getWindowsDirectory for determining the Windows directory
- WritePrivateProfileString/GetPrivateProfileString for writing and

reading
the ini-file.

For quite some time this has worked without any problems. On most systems

I
have it still works (i.e. XP Home SP2 with Excel 2003 SP2; XP Pro SP2 with
Excel 2000 SP3). However a user has a laptop (XP Pro SP2 + Excel 2003 SP2)
where these functions do not work!!
The function getWindowsDirectory returns no result and the functions
WritePrivateProfileString and GetPrivataProfileString do not work

correctly.

Does anyone know (the cause of) this problem?
How could I solve this issue?

I'm looking for some general solution that will work on all the different
environments.

Thanx in advance
Youp





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Problems with reading / writing ini-file

What about apiGetWindowsDirectory?

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Youp" wrote in message
...
Hi,

This is the code that I currently use:

lngx = apiGetWindowsDirectory(strIniFile, Len(strIniFile))
If lngx < 0 Then
GetIniFileName = Left(strIniFile, lngx) & "\" & "PTPT.ini"
Else
GetIniFileName = Empty
End If

So the principle is the same as in your example.

Youp


"Bob Phillips" wrote:

Does your code look like

Dim sDir As String
Dim cLength As Long

sDir = Space(255)
cLength = GetSystemDirectory(sDir, 255)
sDir = Left(sDir, cLength)
Debug.Print "System directory path: "; sDir


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Youp" wrote in message
...
Hi,

I have an Excel workbook that uses an ini-file.

The principle I'm using is as follows:
There is a basic sheet that is used to create calculations. The user

always
opens the basis sheet when creating new calculations. When opening

this
file,
it is checked whether a certain ini-file is present. If not the data

for
this
file has to be entered first (via a form that is called from the

sheet).
Some
things that are stored in this ini-file are the file location for

storing
the
calculations and a sequence number that is used for creating

file-names
for
the calculation.

When the user is ready with his calculation, the user presses a button

in
the sheet. This will do the following: a unique name for the

calculation
is
created (using the seq. number from the ini-file); the calculation is

save
using this name; the sequence number in the ini-file is increased).

For reading / writing the ini-file I use:
- getWindowsDirectory for determining the Windows directory
- WritePrivateProfileString/GetPrivateProfileString for writing and

reading
the ini-file.

For quite some time this has worked without any problems. On most

systems
I
have it still works (i.e. XP Home SP2 with Excel 2003 SP2; XP Pro SP2

with
Excel 2000 SP3). However a user has a laptop (XP Pro SP2 + Excel 2003

SP2)
where these functions do not work!!
The function getWindowsDirectory returns no result and the functions
WritePrivateProfileString and GetPrivataProfileString do not work

correctly.

Does anyone know (the cause of) this problem?
How could I solve this issue?

I'm looking for some general solution that will work on all the

different
environments.

Thanx in advance
Youp







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Problems with reading / writing ini-file

It's declared as follows:

Private Declare Function apiGetWindowsDirectory& Lib "kernel32" Alias
"GetWindowsDirectoryA" _
(ByVal lpbuffer As String, ByVal nSize As Long)

I tried the function you're mentioning on my XP Pro / Excel 2000 environment
(which is working fine with the above function) and this results in an error
(Microsoft Excel for Windows has encountered a problem and needs to close...).

Youp




"Bob Phillips" wrote:

What about apiGetWindowsDirectory?

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Youp" wrote in message
...
Hi,

This is the code that I currently use:

lngx = apiGetWindowsDirectory(strIniFile, Len(strIniFile))
If lngx < 0 Then
GetIniFileName = Left(strIniFile, lngx) & "\" & "PTPT.ini"
Else
GetIniFileName = Empty
End If

So the principle is the same as in your example.

Youp


"Bob Phillips" wrote:

Does your code look like

Dim sDir As String
Dim cLength As Long

sDir = Space(255)
cLength = GetSystemDirectory(sDir, 255)
sDir = Left(sDir, cLength)
Debug.Print "System directory path: "; sDir


--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Youp" wrote in message
...
Hi,

I have an Excel workbook that uses an ini-file.

The principle I'm using is as follows:
There is a basic sheet that is used to create calculations. The user
always
opens the basis sheet when creating new calculations. When opening

this
file,
it is checked whether a certain ini-file is present. If not the data

for
this
file has to be entered first (via a form that is called from the

sheet).
Some
things that are stored in this ini-file are the file location for

storing
the
calculations and a sequence number that is used for creating

file-names
for
the calculation.

When the user is ready with his calculation, the user presses a button

in
the sheet. This will do the following: a unique name for the

calculation
is
created (using the seq. number from the ini-file); the calculation is

save
using this name; the sequence number in the ini-file is increased).

For reading / writing the ini-file I use:
- getWindowsDirectory for determining the Windows directory
- WritePrivateProfileString/GetPrivateProfileString for writing and
reading
the ini-file.

For quite some time this has worked without any problems. On most

systems
I
have it still works (i.e. XP Home SP2 with Excel 2003 SP2; XP Pro SP2

with
Excel 2000 SP3). However a user has a laptop (XP Pro SP2 + Excel 2003

SP2)
where these functions do not work!!
The function getWindowsDirectory returns no result and the functions
WritePrivateProfileString and GetPrivataProfileString do not work
correctly.

Does anyone know (the cause of) this problem?
How could I solve this issue?

I'm looking for some general solution that will work on all the

different
environments.

Thanx in advance
Youp








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
Need sample for reading value from and writing value to cell E53 from outside Excel Tony Bansten Excel Discussion (Misc queries) 1 June 17th 08 07:03 AM
Reading Writing Data from One WorkBook to Another John Pierce Excel Programming 0 May 30th 05 09:23 PM
question about Excel file writing and reading Albert Ge Excel Programming 2 April 25th 05 09:12 AM
Fast reading/writing of CSV files Chris Jakeman Excel Programming 2 August 6th 04 10:29 AM
Reading and writing from/into several worksheets Chris Excel Programming 3 December 4th 03 08:24 PM


All times are GMT +1. The time now is 09:43 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"