View Single Post
  #33   Report Post  
Posted to microsoft.public.excel.programming
Auric__ Auric__ is offline
external usenet poster
 
Posts: 538
Default IP address to Hostname in Excel

Peter T wrote:

"Andrey G" wrote in message
On Friday, April 14, 2017 at 12:39:40 AM UTC+1,
wrote:
Agreed - thanks Randy and apologies for the confusion re
Windows/Office versions :)

Simon


Dear all,
At work, I've inherited the file that's using Randy Birch's code from
he
http://vbnet.mvps.org/index.html?cod...byhostname.htm.
Recently, all machines have been up-dated to Office 64 bit and the code
stopped working.
I've tried everything from Peter T suggestions above, but, still, as
soon as the code gets to line: CopyMemory ptrName, ByVal ptrName, 4,
Excel crashes.
I feel particularly stupid, as it looks that some people in this
conversation have actually managed to adjust original code to 64 bit,
following Peter T's advice.
Any help will be greatly appreciated!

Andrey G


What were my 'suggestions above'...?

It looks like you're attempting to copy a pointer which in x64 will be
an 8-bit LongLong, or a 4-bit Long in x32


<pedantic=on 8-byte LongLong, 4-byte Long </pedantic=off

Try declaring this conditional constant, either as public in a normal
module or as private in the module you call CopyMemory

#If Win64 Then
Public Const gcPtrBytes As Long = 8
#Else
Public Const gcPtrBytes As Long = 4
#End If

and
CopyMemory ptrName, ByVal ptrName, gcPtrBytes

Only a guess with not much to go on!

Peter T


API calls declared PtrSafe?

#If Win64 (or #If Vba7)
Declare Sub PtrSafe CopyMemory etc.

--
- I just hope you know what you're doing.
- I hope that same thing, on occasion.