32 bit vs 64 bit

ericlch16

Active Member
Joined
Nov 2, 2007
Messages
311
Office Version
  1. 2016
  2. 2013
Platform
  1. Windows
Hi

My excel was recently upgraded to 64 bit.

the following function was working in 32 bit but not 64 bit.

Any reason why? i have changed the Long to LongPtr but still does not work.

Function IsFileOpen(strFullPathFileName As String) As Boolean
'// VBA version to check if File is Open
'// We can use this for ANY FILE not just Excel!
'// Ivan F Moala
'// http://www.xcelfiles.com

Dim hdlFile As Long

'// Error is generated if you try
'// opening a File for ReadWrite lock >> MUST BE OPEN!
On Error GoTo FileIsOpen:
hdlFile = FreeFile
Open strFullPathFileName For Random Lock Read Write As hdlFile
IsFileOpen = False
Close hdlFile
Exit Function
FileIsOpen:
'// Someone has it open!
IsFileOpen = True
Close hdlFile
End Function
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
I am not sure what is wrong but you have not given us all the needed information:

  1. You have not said what "does not work" means. What do you expect to happen and what actually happens?
  2. You do not show what you changed from Long to LongPtr
  3. You have not shown the definition for FreeFile
  4. You have not declared IsFileOpen
Generally a 64-bit problem occurs when you declare API calls. Please show us the code for the entire module. A problem is often not where you think it is in the code.
 
Upvote 0
You do not need to alter anything in that function as it's basic VB IO operations. As Jeff mentioned, you only need to alter API calls.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,205
Messages
6,123,632
Members
449,109
Latest member
Sebas8956

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