ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro error please help (https://www.excelbanter.com/excel-discussion-misc-queries/82833-macro-error-please-help.html)

Francesco

Macro error please help
 
Hello

I am trying to use thi following macro but I get an error saing KERNEL
cannot be found and this occurs at the macro line " y= ......"

What I am doing wrong?
I am Using WindowXP Professional and Excel 2003

'The following two declare statements need to be entered each on a single
'line in the module sheet.

Declare Function GetSystemDirectory Lib "KERNEL" (ByVal lpBuffer As String,
ByVal nSize As Integer) As Integer

Declare Function GetWindowsDirectory Lib "KERNEL" (ByVal lpBuffer As String,
ByVal nSize As Integer) As Integer

Sub GetDir()
'sets the buffer length for both variables to 144
Dim Win_Dir As String * 144
Dim Sys_Dir As String * 144
'returns the \Windows directory
y = GetWindowsDirectory(Win_Dir, Len(Win_Dir))
'Displays the windows directory in a Message box
MsgBox Win_Dir
'Returns the Windows\System directory
x = GetSystemDirectory(Sys_Dir, Len(Win_Dir))
'Displays the \Windows\System directory in a Message box
MsgBox Sys_Dir
End Sub

thanks for the help
Francesco

Ardus Petus

Macro error please help
 
Declare Function GetSystemDirectory Lib "KERNEL32.DLL" Alias
"GetSystemDirectoryA" _
(ByVal lpBuffer As String, ByVal nSize As Integer) As Integer

Declare Function GetWindowsDirectory Lib "KERNEL32.DLL" Alias
"GetWindowsDirectoryA" _
(ByVal lpBuffer As String, ByVal nSize As Integer) As Integer

HTH
--
AP

"Francesco" a écrit dans le message de
...
Hello

I am trying to use thi following macro but I get an error saing KERNEL
cannot be found and this occurs at the macro line " y= ......"

What I am doing wrong?
I am Using WindowXP Professional and Excel 2003

'The following two declare statements need to be entered each on a single
'line in the module sheet.

Declare Function GetSystemDirectory Lib "KERNEL" (ByVal lpBuffer As

String,
ByVal nSize As Integer) As Integer

Declare Function GetWindowsDirectory Lib "KERNEL" (ByVal lpBuffer As

String,
ByVal nSize As Integer) As Integer

Sub GetDir()
'sets the buffer length for both variables to 144
Dim Win_Dir As String * 144
Dim Sys_Dir As String * 144
'returns the \Windows directory
y = GetWindowsDirectory(Win_Dir, Len(Win_Dir))
'Displays the windows directory in a Message box
MsgBox Win_Dir
'Returns the Windows\System directory
x = GetSystemDirectory(Sys_Dir, Len(Win_Dir))
'Displays the \Windows\System directory in a Message box
MsgBox Sys_Dir
End Sub

thanks for the help
Francesco





All times are GMT +1. The time now is 02:47 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com