[AccessD] Windows 7

Tony Septav iggy at nanaimo.ark.com
Fri Jan 14 11:08:28 CST 2011


Hey Rocky
Thanks.
That is what I have done and I just sent it off to the client, hope it 
works.
I did try searching the DataBaseAdvisors Archive earlier this morning 
for Windows 7 and CommonDialog but all I got was "Oops No link....."

Rocky Smolin wrote:

>So you think it's the ActiveX control?
>
>Couple days ago there was a solution to this, I think, from Stuart replacing
>the ComDialog with API calls.  Posted below.
>
>Rocky
>
>  
>
>>I've been using the ComDialog control to choose folders and such but 
>>it doesn't work with Vista/Windows 7.
>>
>>Any suggestions to replace it?
>>    
>>
>
>Windows API calls.
>
>Here ya go. It's what I always use instead of the control.   First one for
>File selection, second 
>for Folder selection.\:
>
>'-----------------------------------
>'For files:
>'--------------------------------------
>Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
>         "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
>
>Type OPENFILENAME
>    lStructSize As Long
>    hwndOwner As Long
>    hInstance As Long
>    lpstrFilter As String
>    lpstrCustomFilter As String
>    nMaxCustFilter As Long
>    nFilterIndex As Long
>    lpstrFile As String
>    nMaxFile As Long
>    lpstrFileTitle As String
>    nMaxFileTitle As Long
>    lpstrInitialDir As String
>    lpstrTitle As String
>    flags As Long
>    nFileOffset As Integer
>    nFileExtension As Integer
>    lpstrDefExt As String
>    lCustData As Long
>    lpfnHook As Long
>    lpTemplateName As String
>End Type
>
>Function GetFileName(Directory As String) As String
>    Dim OpenFile As OPENFILENAME
>    Dim lReturn As Long
>    Dim sFilter As String
>    OpenFile.lStructSize = Len(OpenFile)
>    OpenFile.hwndOwner = 0
>    OpenFile.hInstance = 0
>    sFilter = "" & Chr(0)
>    OpenFile.lpstrFilter = sFilter
>    OpenFile.nFilterIndex = 0
>    OpenFile.lpstrFile = String(257, 0)
>    OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
>    OpenFile.lpstrFileTitle = OpenFile.lpstrFile
>    OpenFile.nMaxFileTitle = OpenFile.nMaxFile
>    OpenFile.lpstrInitialDir = Directory
>    OpenFile.lpstrTitle = "Select File"
>    OpenFile.flags = 0
>    lReturn = GetOpenFileName(OpenFile)
>    GetFileName = Left$(OpenFile.lpstrFile, InStr(OpenFile.lpstrFile,
>Chr$(0)) - 1) End Function
>
>'----------------------------------
>'For Folders
>'----------------------------------
>
>Option Compare Database
>Option Explicit
>
>Public Declare Function SHBrowseForFolder Lib "shell32.dll" _
>   Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
>
>Public Declare Function SHGetPathFromIDList Lib "shell32.dll" _
>   Alias "SHGetPathFromIDListA" _
>  (ByVal pidl As Long, _
>   ByVal pszPath As String) As Long
>    
>Public Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal pv As Long)
>
>Public Type BROWSEINFO    'BI
>    hOwner As Long
>    pidlRoot As Long
>    pszDisplayName As String
>    lpszTitle As String
>    ulFlags As Long
>    lpfn As Long
>    lParam As Long
>    iImage As Long
>End Type
>
>Function GetFolder() As String
>  Dim pidl As Long
>  Dim BI As BROWSEINFO
>  Dim sPath As String
>  Dim pos As Integer
> 
>  'Fill BROWSEINFO structure data
>   With BI
>      .hOwner = 0
>      .pidlRoot = 0
>      .lpszTitle = "Browsing"
>      .ulFlags = 1
>      .pszDisplayName = Space$(260)
>   End With
>  
>  'show dialog returning pidl to selected item
>   pidl = SHBrowseForFolder(BI)
> 
>  'if pidl is valid, parse & return the user's selection
>   sPath = Space$(260)
>    
>   If SHGetPathFromIDList(ByVal pidl, ByVal sPath) Then
>   
>     'SHGetPathFromIDList returns the absolute
>     'path to the selected item. No path is returned for virtual folders.
>      pos = InStr(sPath, Chr$(0))
>      If pos Then GetFolder = Left(sPath, pos - 1)
>   Else:
>     GetFolder = ""
>   End If
> 'free the pidl
>   Call CoTaskMemFree(pidl)
>End Function
> 
>
>-----Original Message-----
>From: accessd-bounces at databaseadvisors.com
>[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Tony Septav
>Sent: Friday, January 14, 2011 6:37 AM
>To: Access Developers discussion and problem solving
>Subject: Re: [AccessD] Windows 7
>
>Hey Rocky
>No a test bed is not an option at the moment.  I could get them to set the
>compatability mode for Access2003 or rewrite the code for the commondialog
>and not use an activex control. But I am just wondering how this is going to
>affect other standalone applications I have designed in
>Access2003 for other clients.
>
>Rocky Smolin wrote:
>
>  
>
>>I put W7 on my backup box so I don't do much Access over there.  But 
>>what I have done - so far no problems.  Do you have a spare box you 
>>could put W7 on and use for a test bed?
>>
>>Rocky
>>
>>
>>-----Original Message-----
>>From: accessd-bounces at databaseadvisors.com
>>[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Tony Septav
>>Sent: Friday, January 14, 2011 6:11 AM
>>To: Access Developers discussion and problem solving
>>Subject: [AccessD] Windows 7
>>
>>Hey All
>>I have an Access2003 program (MDE) used by a client, they have upgraded 
>>their machines to Windows 7  and now they get the dreaded  "The 
>>OpenForm action was cancelled" when they click the button on the main 
>>menu for one option (the others all work fine). The only thing this 
>>form has that the others don't is a CommonDialog control.  I haven't as 
>>yet had them check for missing references (the office doesn't open 
>>until 8AM, I may have to send them the MDB to check).  They startup the 
>>program with their version of Access2003.  In trying to research the 
>>cause of this problem,  I am seeing that  Access2003 can develop some
>>    
>>
>problems when running under Windows 7.
>  
>
>>Have any of you run into other  problems?
>>
>>Thanks
>>Tony
>>
>>--
>>AccessD mailing list
>>AccessD at databaseadvisors.com
>>http://databaseadvisors.com/mailman/listinfo/accessd
>>Website: http://www.databaseadvisors.com
>>
>> 
>>
>>    
>>
>
>--
>AccessD mailing list
>AccessD at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/accessd
>Website: http://www.databaseadvisors.com
>
>  
>




More information about the AccessD mailing list