Link to home
Start Free TrialLog in
Avatar of joeserrone
joeserrone

asked on

WshShell.SendKeys "{F5}"

I have a MS Access database with the following code in the on-click event of a button, I am trying to see how I can insert a WshShell.SendKeys "{F5}" so that the dialog file on the list is automatically updated with the latest information uploaded on the SharePoint Site. I haven't been able to figure out how to do this in my existing form
'needs reference to microsoft office 12.0 object library
   Dim MyFilePath As String
   Dim MyFileDialog As Office.FileDialog
   Dim MyfileDFilter As Office.FileDialogFilter
   Dim strPath As String

   Set MyFileDialog = Application.FileDialog(msoFileDialogFilePicker)

   strPath = "http://teamsites......." '<<<<The SharePoint Site

   With MyFileDialog
      .Title = "Select Pic"
      .Filters.Clear
      .Filters.Add "Image Files", "*.jpg, *.bmp, *.gif"
      
      .FilterIndex = 2
      
      .ButtonName = "Select"
      .InitialView = msoFileDialogViewDetails
      .InitialFileName = strPath
      If .Show = -1 Then
         MyFilePath = CStr(MyFileDialog.SelectedItems.Item(1))
      Else
        
      End If
   End With
Me.txtFilePath = MyFilePath

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of YohanF
YohanF
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of joeserrone
joeserrone

ASKER

I tried placing WshShell.SendKeys "{F5}" and also me.refresh on line 8 of my code but didn't work, do you have any ideas how my code would look like?
Does the dialog file open from the initial folder location you have given, it should be automatically refreshed without having to explicitly do it.. Or am I understanding the problem wrong?
I thought that too but it doesn't refresh it, I have to manually press F5 in order to refresh it
So when you press the F5 key does that get refreshed???

Also check whether there is a caching mechanism in your network, that could be a problem causer...

what about DoCmd.RunCommand acCmdRefresh command ?? also insert that just before "If .Show = -1 Then" line....

Hope this will work for you..

Avatar of Jeffrey Coachman
I don't see {F5} anywhere in the code you posted?

Can you post the code where you tried it and it did not work?
I tried the "DoCmd.RunCommand acCmdRefresh " option but didn't work, to answer Boag2000 question... attached is the code I tried to run using the {F5} option
'needs reference to microsoft office 12.0 object library
   Dim MyFilePath As String
   Dim MyFileDialog As Office.FileDialog
   Dim MyfileDFilter As Office.FileDialogFilter
   Dim strPath As String

   Set MyFileDialog = Application.FileDialog(msoFileDialogFilePicker)
WshShell.SendKeys "{F5}" 
   strPath = "http://teamsites......." '<<<<The SharePoint Site

   With MyFileDialog
      .Title = "Select Pic"
      .Filters.Clear
      .Filters.Add "Image Files", "*.jpg, *.bmp, *.gif"
      
      .FilterIndex = 2
      
      .ButtonName = "Select"
      .InitialView = msoFileDialogViewDetails
      .InitialFileName = strPath
      If .Show = -1 Then
         MyFilePath = CStr(MyFileDialog.SelectedItems.Item(1))
      Else
        
      End If
   End With
Me.txtFilePath = MyFilePath

Open in new window

This advice is good but I can't get it to work on my code