+ Reply to Thread
Results 1 to 2 of 2

Macro error please help

  1. #1
    Francesco
    Guest

    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

  2. #2
    Ardus Petus
    Guest

    Re: 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" <Francesco@discussions.microsoft.com> a écrit dans le message de
    news:BE291A34-4202-4DD3-8CEE-326D21DEEBFE@microsoft.com...
    > 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




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1