look for file update over the internet (1 Viewer)

smig

Registered User.
Local time
Tomorrow, 01:17
Joined
Nov 25, 2009
Messages
2,209
Hi

I need a way to look for a file update over the internet.
I know where the file will be (It is my WebSite)
What I really need is a way to read the file name exist in the specific internet folder.

Thanks
 

smig

Registered User.
Local time
Tomorrow, 01:17
Joined
Nov 25, 2009
Messages
2,209
You're in luck!
See my example app - Create a web version checker

I noticed you use this kind of code for 64/32 bit Windows or Office
Code:
#If VBA7 Then 'Add PtrSafe - required for 64-bit Office (VBA7)
    Declare PtrSafe Function acb_apiGetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
#ElseIf Win64 Then 'need datatype LongPtr
    Declare PtrSafe Function acb_apiGetTickCount Lib "kernel32" Alias "GetTickCount" () As LongPtr
#Else '32-bit Office
    Declare Function acb_apiGetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
#End If

Is it really required?
I have no problem declaring all as PtrSafe and compile it and make it works both under Office 64 or 32 bit
 

theDBguy

I’m here to help
Staff member
Local time
Today, 16:17
Joined
Oct 29, 2018
Messages
21,358
I noticed you use this kind of code for 64/32 bit Windows or Office
Code:
#If VBA7 Then 'Add PtrSafe - required for 64-bit Office (VBA7)
    Declare PtrSafe Function acb_apiGetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
#ElseIf Win64 Then 'need datatype LongPtr
    Declare PtrSafe Function acb_apiGetTickCount Lib "kernel32" Alias "GetTickCount" () As LongPtr
#Else '32-bit Office
    Declare Function acb_apiGetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
#End If
Is it really required?
I have no problem declaring all as PtrSafe and compile it and make it works both under Office 64 or 32 bit
Hi. I believe Isladog's approach is just trying to cover all bases. It may not be required for some situations, but it may be necessary for others. For example, do you have any Access 2007 or earlier users?
 

isladogs

MVP / VIP
Local time
Today, 23:17
Joined
Jan 14, 2017
Messages
18,186
Hi smig/DBGuy
You're both right!

The code was written in about 2012 when most of my clients were still using A2007. With the advent of A2010 (32-bit & 64-bit), VBA7 was introduced and I started using conditional compilation for all possible client configurations.
However the API code I used then was over complicated & in this case also contained some mistakes :eek:.

I have used this opportunity to simplify & correct the APIs in this app.
As I still have some clients using A2007, I still use conditional compilation.
The example you posted has been changed to:

Code:
'CR - APIs updated 07/10/2019
'###############################################
#If VBA7 Then 'for use with 32/64-bit Access (2010 onwards)
 [B]   Declare PtrSafe Function acb_apiGetTickCount Lib "kernel32" Alias "GetTickCount" () As Long[/B]
#Else 'for A2007 (or earlier)
    Declare Function acb_apiGetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
#End If

If all of your users are on A2010 or later you just need the lines in bold type. Similarly for the other APIs in this app.

Hope that helps & thanks for alerting me to this.
I have posted the update to sample databases as well
 

Attachments

  • WebVersionChecker_v2.zip
    56.1 KB · Views: 61
Last edited:

smig

Registered User.
Local time
Tomorrow, 01:17
Joined
Nov 25, 2009
Messages
2,209
Hi smig/DBGuy
You're both right!

The code was written in about 2012 when most of my clients were still using A2007. With the advent of A2010 (32-bit & 64-bit), VBA7 was introduced and I started using conditional compilation for all possible client configurations.
However the API code I used then was over complicated & in this case also contained some mistakes :eek:.

I have used this opportunity to simplify & correct the APIs in this app.
As I still have some clients using A2007, I still use conditional compilation.
The example you posted has been changed to:

Code:
'CR - APIs updated 07/10/2019
'###############################################
#If VBA7 Then 'for use with 32/64-bit Access (2010 onwards)
 [B]   Declare PtrSafe Function acb_apiGetTickCount Lib "kernel32" Alias "GetTickCount" () As Long[/B]
#Else 'for A2007 (or earlier)
    Declare Function acb_apiGetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
#End If

If all of your users are on A2010 or later you just need the lines in bold type. Similarly for the other APIs in this app.

Hope that helps & thanks for alerting me to this.
I have posted the update to sample databases as well

Thanks a lot :)
All my users are using Access 2010, as I use the new Ribbon system which will not work in old versions of Access.

Now I have another question in this matter :D
how do I differ Access 64bit and 32bit versions?

something like
Code:
#If OfficeIs64Bit Then
   ' code for 64 bit Office
#Else
   ' code for 32 bit Office
#End If
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 23:17
Joined
Jan 14, 2017
Messages
18,186
The ribbon is irrelevant to any discussion about APIs.

You are very fortunate that all your users have the same Access version. As they all use 2010, all have VBA7. This means you can scrap conditional compilation and just use the VBA7 version of the declaration as it will work with both 'bitnesses'.
You may occasionally need to do conditional #If Win64 Then statements for items that only work in 64-bit but that's rarely necessary.

However you do need to realise that some VBA references (e.g. ComnonControls) and certain ActiveX controls (including Flexgrid and Treeview) do not work in 64-bit. In such cases you will need to rewrite your code

EDIT
Posts crossed. I use the following code in a standard module to detect /report the bitness

Code:
Function IsWin32OrWin64()

'Determine if operating system is 32-bit or 64-bit
    '-------------------------------------------------
    'Modified from code provided at:
    '  http://www.vb-helper.com/howto_get_os_name.html
    Dim proc_query As String
    Dim proc_results As Object
    Dim Info As Object
    
    proc_query = "SELECT * FROM Win32_Processor"
    Set proc_results = GetObject("Winmgmts:").ExecQuery(proc_query)
    For Each Info In proc_results
        IsWin32OrWin64 = Info.AddressWidth & "-bit"
    Next Info
    
    'Debug.Print IsWin32OrWin64
End Function

Function IsOfficex64()
'checks if Office is 32 or 64 bit

#If Win64 Then
  IsOfficex64 = "64-bit"
#Else
  IsOfficex64 = "32-bit"
#End If

'Debug.Print IsOfficex64

End Function

Have a look at my Access Version checker app https://www.access-programmers.co.uk/forums/showthread.php?t=302910
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 16:17
Joined
Oct 29, 2018
Messages
21,358
Just to basically repeat what Colin said, I think VBA7 is what you were asking about, but as already mentioned, it's not required if all users are post Access 2010. Also, just to clarify the bit about Common Controls and TreeView, they also don't affect this discussion on updating API declarations. When he said you have to update your code for those controls, I don't think he was referring to using conditional compilations. Cheers!
 

smig

Registered User.
Local time
Tomorrow, 01:17
Joined
Nov 25, 2009
Messages
2,209
The ribbon is irrelevant to any discussion about APIs.

You are very fortunate that all your users have the same Access version. As they all use 2010, all have VBA7. This means you can scrap conditional compilation and just use the VBA7 version of the declaration as it will work with both 'bitnesses'.
You may occasionally need to do conditional #If Win64 Then statements for items that only work in 64-bit but that's rarely necessary.

However you do need to realise that some VBA references (e.g. ComnonControls) and certain ActiveX controls (including Flexgrid and Treeview) do not work in 64-bit. In such cases you will need to rewrite your code

I already understood, from this discussion :), that I only need the VBA7 style of declaration (What I already had)

If we go back to the start of the topic, what I wanted to do is to let the users automatically find and download an update version of my app.
For this I should know if the user is running the 32 or 64 bit version of Office.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 16:17
Joined
Oct 29, 2018
Messages
21,358
I already understood, from this discussion :), that I only need the VBA7 style of declaration (What I already had)

If we go back to the start of the topic, what I wanted to do is to let the users automatically find and download an update version of my app.
For this I should know if the user is running the 32 or 64 bit version of Office.
Oh, I see... For that, and Colin can correct me if I am wrong, but I think you may have to go to the Registry to find out. Check out Colin's demo on finding out the version and bitness to see how he did it. Cheers!
 

smig

Registered User.
Local time
Tomorrow, 01:17
Joined
Nov 25, 2009
Messages
2,209
The ribbon is irrelevant to any discussion about APIs.

You are very fortunate that all your users have the same Access version. As they all use 2010, all have VBA7. This means you can scrap conditional compilation and just use the VBA7 version of the declaration as it will work with both 'bitnesses'.
You may occasionally need to do conditional #If Win64 Then statements for items that only work in 64-bit but that's rarely necessary.

However you do need to realise that some VBA references (e.g. ComnonControls) and certain ActiveX controls (including Flexgrid and Treeview) do not work in 64-bit. In such cases you will need to rewrite your code

EDIT
Posts crossed. I use the following code in a standard module to detect /report the bitness

Code:
Function IsWin32OrWin64()

'Determine if operating system is 32-bit or 64-bit
    '-------------------------------------------------
    'Modified from code provided at:
    '  http://www.vb-helper.com/howto_get_os_name.html
    Dim proc_query As String
    Dim proc_results As Object
    Dim Info As Object
    
    proc_query = "SELECT * FROM Win32_Processor"
    Set proc_results = GetObject("Winmgmts:").ExecQuery(proc_query)
    For Each Info In proc_results
        IsWin32OrWin64 = Info.AddressWidth & "-bit"
    Next Info
    
    'Debug.Print IsWin32OrWin64
End Function

Function IsOfficex64()
'checks if Office is 32 or 64 bit

#If Win64 Then
  IsOfficex64 = "64-bit"
#Else
  IsOfficex64 = "32-bit"
#End If

'Debug.Print IsOfficex64

End Function

Have a look at my Access Version checker app https://www.access-programmers.co.uk/forums/showthread.php?t=302910

I look at this code and wonder if the "#If Win64" show the Office 32/64 bit version or the OS one ? :eek:
Code:
Function IsOfficex64()
'checks if Office is 32 or 64 bit

#If Win64 Then
  IsOfficex64 = "64-bit"
#Else
  IsOfficex64 = "32-bit"
#End If

'Debug.Print IsOfficex64

End Function
 

theDBguy

I’m here to help
Staff member
Local time
Today, 16:17
Joined
Oct 29, 2018
Messages
21,358
I look at this code and wonder if the "#If Win64" show the Office 32/64 bit version or the OS one ? :eek:
Code:
Function IsOfficex64()
'checks if Office is 32 or 64 bit

#If Win64 Then
  IsOfficex64 = "64-bit"
#Else
  IsOfficex64 = "32-bit"
#End If

'Debug.Print IsOfficex64

End Function
Hmm, I'm not entirely sure but I believe conditional compilation constants won't show you anything. It's only visible to the compiler. You know, just before the code runs? Like I said earlier, you may have to go to the Registry instead.
 

isladogs

MVP / VIP
Local time
Today, 23:17
Joined
Jan 14, 2017
Messages
18,186
Sorry.
Confusingly, I posted code that checks the OS bitness - IsWin32OrWin64 as well as code that checks the Office bitness - IsOffice64.

Both of these do work. No need to use the registry.

Although the registry does contain information about versions and bitness, I mainly use WMI code to extract information about hardware, OS and software such as Office.

Both DBG and I linked to my Access version checker app.
The really difficult bit was detecting whether users are running Office 365 or the retail version of Office 2016/2019. This was made really complicated by all using the same range of version info 16.0.....+
 

smig

Registered User.
Local time
Tomorrow, 01:17
Joined
Nov 25, 2009
Messages
2,209
Sorry.
Confusingly, I posted code that checks the OS bitness - IsWin32OrWin64 as well as code that checks the Office bitness - IsOffice64.

Both of these do work. No need to use the registry.

Although the registry does contain information about versions and bitness, I mainly use WMI code to extract information about hardware, OS and software such as Office.

Both DBG and I linked to my Access version checker app.
The really difficult bit was detecting whether users are running Office 365 or the retail version of Office 2016/2019. This was made really complicated by all using the same range of version info 16.0.....+
Yes, I looked at your code

I'm looking into the IsOfficex64 one, and there you check for Win64.
I like it's simplicity, but does it realy check for the Office64/32 or for the OS ?
This one made me confused and I want to make sure

Code:
Function IsOfficex64()
'checks if Office is 32 or 64 bit

#If Win64 Then
  IsOfficex64 = "64-bit"
#Else
  IsOfficex64 = "32-bit"
#End If

'Debug.Print IsOfficex64

End Function
 

theDBguy

I’m here to help
Staff member
Local time
Today, 16:17
Joined
Oct 29, 2018
Messages
21,358
Yes, I looked at your code

I'm looking into the IsOfficex64 one, and there you check for Win64.
I like it's simplicity, but does it realy check for the Office64/32 or for the OS ?
This one made me confused and I want to make sure

Code:
Function IsOfficex64()
'checks if Office is 32 or 64 bit

#If Win64 Then
  IsOfficex64 = "64-bit"
#Else
  IsOfficex64 = "32-bit"
#End If

'Debug.Print IsOfficex64

End Function
Hi. I hope this doesn't add any confusions, but check out this link.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 16:17
Joined
Oct 29, 2018
Messages
21,358
I already looked at this, and it totally confused me :confused:
i trust Colin :)
Sorry about that. But the way I read it, Win64 does reflect if the Office environment is 32- or 64-bit. For example, let's take a look at the Conclusion paragraph of this article, it says:
Conclusion

VBA 7.0 is the latest version of VBA that improves the performance of applications that are created in Office 2010. To enable you to continue using your legacy solutions in different versions of Microsoft Office, the VBA7 compilation constant is available. Likewise, because there is now a 32-bit version and 64-bit version of Office 2010, you use the Win64 compilation constant to direct the compiler to the run the correct section of code in your VBA applications.
 

isladogs

MVP / VIP
Local time
Today, 23:17
Joined
Jan 14, 2017
Messages
18,186
To answer some of the recent points i need to do a bit of a preamble

My earlier conditional compilation code written around 2011-14 was both over-complex but also in the wrong order. At the time I used
Code:
#If VBA7 Then
…
#ElseIf Win64 Then
…
#Else
…
#End If

However using that meant the Win64 section never actually ran as all 64-bit Office versions used VBA7. Later I reversed the order before belatedly realising that the Win64 section wasn't usually necessary.

I wasn't alone in such contortions. For example arnelgp used to use
Code:
#If VBA7 Then
  #If Win64 Then
...
#Else
...
#End if
#Else
...
#End If

He also now uses a simplified approach

Now for Office versions remember #Win64 is always a subset of #VBA7. The converse isn't necessarily true.

The OS version isn't directly relevant though of course whilst you can have 32 bit Office in 64-bit Windows, the reverse isn't possible.
So 64-bit Office always means #If Win64 is true. Otherwise its 32-bit Office even if the OS is 64-bit.

I hope that has clarified things rather than add to any possible confusion

EDIT
In the time it took me to write the above, there were at least 6 more posts including one by smig saying he trusted me ...later deleted! :D

The MS article quote by DBG isn't totally helpful in that it includes a test based on GetTickCount64 and LongLong (rather than the VBA7 universal replacement LongPtr. Whilst that would only work in 64-bit, GetTickCount also works in 64-bit
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Today, 16:17
Joined
Oct 29, 2018
Messages
21,358
Thanks,
This make it more clear now :)
You distinguish the Office version by the way the compiler run the code :D
Whew! Glad to hear we got it somewhat clarified now. I still recommend you take a look at Colin's demo in case it can provide some more hints for you. Cheers!
 

Users who are viewing this thread

Top Bottom