Try this:
Dim lngFile As Integer
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi ,
We have a VBA program that has been working for years. During the test with office 64-bit, we get this error message "Type mismatch" as you can see from the attachment.
This piece of code is used to open a simple existing text file from local drive:
Dim strFileName As String, strFitDir As String
Dim lngFile As LongPtr 'I also tried LongLong
strFitDir = GetDirectory
strFitDir = "c:\eBB\"
strFileName = strFitDir & "Fix3rdPersonList.txt"
On Error GoTo HandleError
lngFile = FreeFile
Open strFileName For Input As #lngFile
I did modify the code a little bit for Office 64-bit based on this suggestion:
Basically I added "PtrSafe" keyword to declare function and use "LongPtr" or "LongLong" to replace "Long" for 64-bit, otherwise I would get some compile errors.
Please show me how to fix this "Type mismatch" error in text file open line:
Open strFileName For Input As #lngFile
Your help will be greatly appreciated.
Try this:
Dim lngFile As Integer