troubleshooting Question

[Urgent] Automating the saving of OLEs to external folder via SendKeys

Avatar of kkamm
kkammFlag for United States of America asked on
Microsoft Access
14 Comments1 Solution597 ViewsLast Modified:
I have a SQL database that has grown too heavy for its own good, and it is filled to the brim with Embedded OLE. This needs to change.

So, I have a good idea of how to export all of my OLEs to an appropriate folder by creating a custom form to accomplish this, give them a unique ID, and create a text link to their location. The only problem I am running into is execution.

1st things 1st, let me give you the important information

1: the tables name is subtblPhysicianNotes
2: The field 'uniqueID' is an integer based IDENTITY field
3: The field 'PhysicianNote' is the Embedded OLE object, all of which for this run are word docs.
4: The field 'PhysicianLink' is a 50 character length text field, which will store the link
5: The text field in which UniqueID is stored is called UniqueID
6: The text field in which PhysicianLink is stored is called PhysicianLink
7: The OLE object PhysicianNote is stored in is called PhysicianNote

Here is the VBA for the form, as it currently stands. I will ((mark)) areas where I need help, and explain what I need help with there.

I seriously need help with this, as the database is becoming quickly unusable.

Function is run at form_open.

Dim strPath As String
Dim strExt As String

strExt =".doc"
strPath = "f:\whoemr\data\attach\subtblphysiciannote\"

    DoCmd.GoToRecord , , acFirst
            ((here I need to start a loop that waits to see that I made it to the end of table))
    me!PhysicianLink = strPath & me!uniqueID & strExt
            ((here I need to know how to launch the OLE field from VBA, as if it were double clicked to start the external application))
   sSleep 5000 'giving the system enough time to parse the document
   Sendkeys("%F") 'Opens file menu
   sSleep 250
   Sendkeys("A") 'selects "save copy as"
   sSleep 1000
           ((here I need to sendkeys a string, AND the data from a field. Essentially I would "like" to [sendkeys(strPath & me!UniqueID & strExt)], but it has not proven very easy. The end result will put the string in the filename field of the save file dialog box))
   sendkeys("{enter}")'saves the file
   ssleep 2000
   sendkeys ("%{F4}")'closes microsoft word
   ssleep  2000
DoCmd.GoToRecord , , acNext
Loop
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 14 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros