Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need sample for reading value from and writing value to cell E53 from outside Excel | Excel Discussion (Misc queries) | |||
Reading Writing Data from One WorkBook to Another | Excel Programming | |||
question about Excel file writing and reading | Excel Programming | |||
Fast reading/writing of CSV files | Excel Programming | |||
Reading and writing from/into several worksheets | Excel Programming |