Opening a file within a file using VB?

Gabbelgak

New Member
Joined
Dec 14, 2016
Messages
22
Good evening, I'm a bit of a novice with access but I'm trying to work on automating some mundane tasks at work.

I want to make a form in access that I can press a button it will switch to my work program, navigate to the correct part (I have this working with AppActivate and SendKeys) but I need to open up files within the program and am not sure how to navigate to the correct file and open it with my limited knowledge. I can get to an open dialog box, and can even get that working fine but I don't want to use the default folder it opens to - how would I make it open something located in say C:\Windows\Test\openthis.ab?

I've attached my button code so you can see what I'm thinking here. I'm sure there are probably better ways to go about this but I'm not very experienced :laugh:

Code:
Private Sub Command0_Click()
AppActivate ("AppNameHere")
SendKeys "%N"
SendKeys "R"
SendKeys "%D"
SendKeys "E"
Dim T1 As Variant
Dim T2 As Variant
 T1 = Now()
 T2 = DateAdd("s", 2, T1)
 Do Until T2 <= T1
 T1 = Now()
Loop
SendKeys "%F"
SendKeys "O" 'A windows "Open" dialog box opens here
 T1 = Now()
 T2 = DateAdd("s", 1, T1)
 Do Until T2 <= T1
 T1 = Now()
Loop
'here I can do SendKeys again to make it type something and open something in that folder but I want to open something elsewhere.
End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
SendKeys is thought by many to be unreliable, thus I've rarely used it. Why don't you just open the file from Access and let Windows handle the decision on which application needs to open it? That would also work around opening to a default folder, no? You might want to look into the msoFileDialogFolderPicker or msoFileDialogFilePicker to see if you can make use of either. You can probably guess which one does what by the name.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,155
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top