Go Back   Access World Forums > Microsoft Access Discussion > Macros

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 05-03-2019, 08:27 AM   #1
ITguy1981
Newly Registered User
 
Join Date: Aug 2011
Posts: 137
Thanks: 12
Thanked 1 Time in 1 Post
ITguy1981 is on a distinguished road
Ribbon not loading because of now using 64bit Office

I'm currently using a custom ribbon that gets a macro error when any of the buttons are clicked. It seems the issue is due to using 64 bit Office now. I've had help with the previous code so I have no idea what needs changed or how to fix the issue.

Current Code:

Private Const VER_PLATFORM_WIN32_NT = 2
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type

Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _
(ByRef lpVersionInformation As OSVERSIONINFO) As Long
Private Declare Function GetFileNameFromBrowseW Lib "shell32" Alias "#63" _
(ByVal hwndOwner As Long, _
ByVal lpstrFile As Long, _
ByVal nMaxFile As Long, _
ByVal lpstrInitialDir As Long, _
ByVal lpstrDefExt As Long, _
ByVal lpstrFilter As Long, _
ByVal lpstrTitle As Long) As Long
Private Declare Function GetFileNameFromBrowseA Lib "shell32" Alias "#63" _
(ByVal hwndOwner As Long, _
ByVal lpstrFile As String, _
ByVal nMaxFile As Long, _
ByVal lpstrInitialDir As String, _
ByVal lpstrDefExt As String, _
ByVal lpstrFilter As String, _
ByVal lpstrTitle As String) As Long

ITguy1981 is offline   Reply With Quote
Old 05-03-2019, 08:35 AM   #2
theDBguy
I知 here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 2,543
Thanks: 29
Thanked 628 Times in 611 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Ribbon not loading because of now using 64bit Office

Hi. First, you'll need to add PtrSafe to all API declarations. Then, you may have to change some data types as well. Here's some references for you to consider: GetVersionEx
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
The Following User Says Thank You to theDBguy For This Useful Post:
Tera (05-04-2019)
Old 05-03-2019, 11:03 AM   #3
ITguy1981
Newly Registered User
 
Join Date: Aug 2011
Posts: 137
Thanks: 12
Thanked 1 Time in 1 Post
ITguy1981 is on a distinguished road
Re: Ribbon not loading because of now using 64bit Office

I was able to resolve the issue by using an If Statement and using the SafePtr option for VBA7. Do you have any insight on my next issue which is a Type mismatch for StrPtr. I'm sure it's related to the same thing, but not sure how to fix it.

Public Function BrowseFiles()
Dim sSave As String

sSave = Space(255)
'If we're on WinNT, call the unicode version of the function
'If IsWinNT Then
GetFileNameFromBrowseW Screen.ActiveForm.hwnd, _
StrPtr(sSave), _
255, _
StrPtr("c:"), _
StrPtr("xlsx"), _
StrPtr("Excel files(*.xlsx)" + Chr$(0) + "*.xlsx" + Chr$(0) + _
"All files (*.*)" + Chr$(0) + "*.*" + Chr$(0)), _
StrPtr("The Title")
'If we're not on WinNT, call the ANSI version of the function
'Else
'GetFileNameFromBrowseA Screen.ActiveForm.hwnd, _
sSave, _
255, _
"c:", _
"txt", _
"All files (*.*)" + Chr$(0) + "*.*" + Chr$(0) + _
"Text files (*.txt)" + Chr$(0) + "*.txt" + Chr$(0), _
"The Title"
'End If

BrowseFiles = Trim(Replace(sSave, Chr$(0), " "))

End Function

ITguy1981 is offline   Reply With Quote
Old 05-03-2019, 11:15 AM   #4
theDBguy
I知 here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 2,543
Thanks: 29
Thanked 628 Times in 611 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Ribbon not loading because of now using 64bit Office

Hi. What does the StrPtr() function look like?
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 05-03-2019, 12:10 PM   #5
ITguy1981
Newly Registered User
 
Join Date: Aug 2011
Posts: 137
Thanks: 12
Thanked 1 Time in 1 Post
ITguy1981 is on a distinguished road
Re: Ribbon not loading because of now using 64bit Office

Basically I have a button that on click runs

Private Sub ImportBrowse_Click()
Me!BrowseTextBox = BrowseFiles()


It opens windows explorer to browse for a file. It works in 32bit Office.
--------------------------------

Public Function BrowseFiles()
Dim sSave As String

sSave = Space(255)
'If we're on WinNT, call the unicode version of the function
'If IsWinNT Then
GetFileNameFromBrowseW Screen.ActiveForm.hwnd, _
StrPtr(sSave), _
255, _
StrPtr("c:"), _
StrPtr("xlsx"), _
StrPtr("Excel files(*.xlsx)" + Chr$(0) + "*.xlsx" + Chr$(0) + _
"All files (*.*)" + Chr$(0) + "*.*" + Chr$(0)), _
StrPtr("The Title")
'If we're not on WinNT, call the ANSI version of the function
'Else
'GetFileNameFromBrowseA Screen.ActiveForm.hwnd, _
sSave, _
255, _
"c:", _
"txt", _
"All files (*.*)" + Chr$(0) + "*.*" + Chr$(0) + _
"Text files (*.txt)" + Chr$(0) + "*.txt" + Chr$(0), _
"The Title"
'End If

BrowseFiles = Trim(Replace(sSave, Chr$(0), " "))

End Function
ITguy1981 is offline   Reply With Quote
Old 05-03-2019, 12:13 PM   #6
theDBguy
I知 here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 2,543
Thanks: 29
Thanked 628 Times in 611 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Ribbon not loading because of now using 64bit Office

Hi. If that's all you need (browse for files), then you might be able to avoid this problem if you don't use API and just use the FileDialog object instead.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
The Following User Says Thank You to theDBguy For This Useful Post:
Tera (05-04-2019)
Old 05-03-2019, 12:46 PM   #7
ITguy1981
Newly Registered User
 
Join Date: Aug 2011
Posts: 137
Thanks: 12
Thanked 1 Time in 1 Post
ITguy1981 is on a distinguished road
Re: Ribbon not loading because of now using 64bit Office

They way it currently is it opens explorer and when you choose the file it saves the path\name in the text box. The user will browse and select an excel file. It puts the excel file path in to the box. Then the user can click update which will then run a procedure to update another table using the selected spreadsheet.

ITguy1981 is offline   Reply With Quote
Old 05-04-2019, 08:39 AM   #8
theDBguy
I知 here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 2,543
Thanks: 29
Thanked 628 Times in 611 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Ribbon not loading because of now using 64bit Office

Quote:
Originally Posted by ITguy1981 View Post
They way it currently is it opens explorer and when you choose the file it saves the path\name in the text box. The user will browse and select an excel file. It puts the excel file path in to the box. Then the user can click update which will then run a procedure to update another table using the selected spreadsheet.
Right, which the FileDialog object can also do, and you avoid problems when using 64-bit Office.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 05-06-2019, 04:56 AM   #9
ITguy1981
Newly Registered User
 
Join Date: Aug 2011
Posts: 137
Thanks: 12
Thanked 1 Time in 1 Post
ITguy1981 is on a distinguished road
Re: Ribbon not loading because of now using 64bit Office

If I use the code you posted for explorer I can select the file, but it does not insert the directory location after selecting the file and open
ITguy1981 is offline   Reply With Quote
Old 05-06-2019, 05:02 AM   #10
ITguy1981
Newly Registered User
 
Join Date: Aug 2011
Posts: 137
Thanks: 12
Thanked 1 Time in 1 Post
ITguy1981 is on a distinguished road
Re: Ribbon not loading because of now using 64bit Office

I've tried this code and the file picker opens, but I need it to fill my text box with the file path of the file chosen.

Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.AllowMultiSelect = False
If .Show Then
selectFile = .SelectedItems(1)
Else
End
End If
End With
Set fd = Nothing
ITguy1981 is offline   Reply With Quote
Old 05-06-2019, 06:42 AM   #11
theDBguy
I知 here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 2,543
Thanks: 29
Thanked 628 Times in 611 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Ribbon not loading because of now using 64bit Office

Quote:
Originally Posted by ITguy1981 View Post
I've tried this code and the file picker opens, but I need it to fill my text box with the file path of the file chosen.

Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.AllowMultiSelect = False
If .Show Then
selectFile = .SelectedItems(1)
Else
End
End If
End With
Set fd = Nothing
Hi. If you only want the user to select a folder, then maybe you should use msoFileDialogFolderPicker instead of msoFileDialogFilePicker. Otherwise, you can parse the filespec returned by the FileDialog object to strip out the filename. Here's one possible example:
Code:
selectFile=Left(.SelectedItems(1),InStrRev(.SelectedItems(1),"\")-1)
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 05-21-2019, 12:03 PM   #12
ITguy1981
Newly Registered User
 
Join Date: Aug 2011
Posts: 137
Thanks: 12
Thanked 1 Time in 1 Post
ITguy1981 is on a distinguished road
Re: Ribbon not loading because of now using 64bit Office

I need the user to select a .xlsx file.
ITguy1981 is offline   Reply With Quote
Old 05-21-2019, 12:05 PM   #13
theDBguy
I知 here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 2,543
Thanks: 29
Thanked 628 Times in 611 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Ribbon not loading because of now using 64bit Office

Quote:
Originally Posted by ITguy1981 View Post
I need the user to select a .xlsx file.
And again, that's not a problem with the FileDialog object and you avoid the issue with using API on 64-bit systems. Try this:
Code:
Dim fd As Object
Set fd = Application.FileDialog(3)
With fd
    If .Show Then
        MsgBox .SelectedItems(1)
    End If
End With
Set fd = Nothing

__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unactivated Office Breaks Ribbon speakers_86 General 0 01-13-2016 10:13 AM
Ribbon + navigation pane lock/Hide on loading... HRakibul Modules & VBA 5 08-20-2014 12:56 AM
Custom Ribbon Not Loading Frothingslosh General 2 05-23-2013 06:15 PM
Front end .accde Office 32bit and 64bit problems gstullo Theory and practice of database design 0 02-24-2012 11:08 AM
Ribbon bar not loading correctly syvers General 1 11-14-2007 12:33 AM




All times are GMT -8. The time now is 05:03 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World