Macro error please help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

macro help 2
Problem with an amended macro. Please help! 4
Undo doesn't work! 4
Network logon 2
VB6 to VB.NET 3
Pull login time and windows username 4
VBA Code to Login to Excel 1
Windows API Functions 3

Back
Top