Excel Macro from 32 to 64 will not run

Pophil

New Member
Joined
Aug 3, 2016
Messages
25
Our work upgraded to Microsoft 365 and this has affected a macro that was run on 32,

1722268843779.png


Here is the original macro

VBA Code:
'                                     5/1/2013  .:\L0sT/:.

Private Declare  Function GetUserName Lib "advapi32.dll" _

    Alias "GetUserNameA" _

    (ByVal lpBuffer As String, _

    ByRef nSize As Long) As Long





And this is what i changed it to





'                                     5/1/2013  .:\L0sT/:.

Private Declare PtrSafe Function GetUserName Lib "advapi32.dll" _

    Alias "GetUserNameA" _

    (ByVal lpBuffer As String, _

    ByRef nSize As Long) As LongPtr

Also tried this

'                                     5/1/2013  .:\L0sT/:.

Private Declare PtrSafe Function GetUserName Lib "advapi32.dll" _

    Alias "GetUserNameA" _

    (ByVal lpBuffer As String, _

    ByRef nSize As Long) As Long



The macro will start to run then eventually close out the excel program.  What am I missing.  Thank you all for your help.





Also does this need to be changed as well for everything to work



'                                     5/1/2013  .:\L0sT/:.

Sub Clear_Temp_Files()

Shell "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8 "

End Sub

Sub Clear_Cookies()

Shell "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2"

End Sub

Sub Clear_History()

Shell "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1"

End Sub

Sub Clear_Form_Data()

Shell "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16"

End Sub

Sub Clear_Saved_Passwords()

Shell "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32"

End Sub

Sub Clear_All()

Shell "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255"

End Sub

Sub Clear_Clear_Add_ons_Settings()

Shell "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351"

End Sub

Sub Clear_4_Tool()

'

    Clear_Temp_Files

    Clear_Cookies

    Clear_History

End Sub
 
Last edited by a moderator:
No, assuming you used the version 6SJ posted and not your version that returns a LongPtr (that is wrong). I'd assume something else is causing the issues.
Sorry last question if I was to use Environ("Username") how exactly would the code look. Thank you again for your help
 
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
A reminder:

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at:

There is no need to repeat the link(s) provided above but if you have posted the question at other places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
Wherever you are using GetUserName (it's not in any of the code you posted) replace it with Environ("username")
 
Upvote 0

Forum statistics

Threads
1,221,419
Messages
6,159,800
Members
451,589
Latest member
Harold14

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top