Code for relative path for uploading cursor from source to destination in vba powerpoint 2010. RRS feed

  • Question

  • I am using the code below to change the cursor pointer which is there in cursors location, but i want the cursor pointer to be located wherever it might be in the system drives and should copy the pointer into cursors location.How can i code the url path to the current directory so that powerpoint and cursor are placed in a folder and when user clicks on macro pointer should be pasted in cursors location and applied to the ppt.

    Private Declare PtrSafe Function LoadCursorFromFile Lib "user32" Alias "LoadCursorFromFileA" (ByVal lpFileName As String) As Long
    Private Declare PtrSafe Function SetSystemCursor Lib "user32" (ByVal hcur As LongPtr, ByVal id As LongPtr) As Long

    Private Const lng_ID As Long = 32512
    Private newCursor As Long

    Sub Sample()
        myDir = Environ("SystemRoot") + "\cursors\xyx.ani"
        newCursor = LoadCursorFromFile(myDir)
        Call SetSystemCursor(newCursor, lng_ID)
    End Sub

    Saturday, October 5, 2013 12:19 PM


  • Hi,

    According to your description,if you want to change cursor pointer which in ppt file folder, copy

    cursor file to the system cursor folder and load it.You can use Scripting.FileSystemObject to

    move files, but copy files into system folders need administrator permissions. I suggest you

    to create a user folder to save your cursor file. Normally you don't need special permissions to

    copy files into user create subfolders on the C: drive;Only the root folder and system folders are

    restricted. You can create a user folder, copy files from application folder, and Load Cursor.

    Here is the code for your reference:

    Public Sub CopyFileDemo()
        Dim fs As Object
        Dim isthere As Boolean
        Dim StrPath As String
        StrPath = "C:\Mycursors"
        Set fs = CreateObject("Scripting.FileSystemObject")
        If Not fs.FolderExists(StrPath) Then
            fs.CreateFolder StrPath
        End If
            fs.CopyFile Application.ActivePresentation.Path + "\aero_busy.ani", StrPath + "\aero_busy.ani"
        newCursor = LoadCursorFromFile(myDir)
        Call SetSystemCursor(StrPath + "\aero_busy.ani", lng_ID)
    End Sub

    Regard & Thanks,

    Tuesday, October 8, 2013 5:14 AM