Solved

WshShell.SendKeys "{F5}"

Posted on 2010-11-11
8
2,356 Views
Last Modified: 2012-05-10
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

0
Comment
Question by:joeserrone
  • 4
  • 3
8 Comments
 
LVL 6

Accepted Solution

by:
YohanF earned 500 total points
Comment Utility
why dont you just use SendKeys "{F5}" or use Refresh function ?
0
 

Author Comment

by:joeserrone
Comment Utility
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?
0
 
LVL 6

Expert Comment

by:YohanF
Comment Utility
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?
0
 

Author Comment

by:joeserrone
Comment Utility
I thought that too but it doesn't refresh it, I have to manually press F5 in order to refresh it
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 6

Expert Comment

by:YohanF
Comment Utility
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..

0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
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?
0
 

Author Comment

by:joeserrone
Comment Utility
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

0
 

Author Closing Comment

by:joeserrone
Comment Utility
This advice is good but I can't get it to work on my code
0

Featured Post

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now