|
|
|
date: Thu, 2 Oct 2008 06:03:01 -0700,
group: microsoft.public.access.activexcontrol
back
Re: Click button on form using VBscript
Hi,
you can make a public function, say MyFunction, in your form, which calls
okbutton_click proc, and then you can run this function as
acc.Forms.Import.MyFunction
--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com
"jdan" wrote in message
news:55DFCA79-26B5-418A-A6EC-9E18FB427EF9@microsoft.com...
> I want to use a VBscript to automate some tasks in Access 2003. The
> database
> has a macro to import data that I want to use. My script appears to work
> up
> to the last line. It opens the form "Import" in the database, inserts
> "C\tmp\" into the textbox, then moves to the OK button. I have to press
> the
> Enter key on the keyboard or click the mouse manually for the script to
> complete. How do I do automate this last step?
>
> I realize that Sendkeys isn't recommended, but I don't know any other way.
> As shown now, it doesn't work.
>
> strTabDir = "C:\tmp\"
> Set acc = createobject("Access.Application")
>
> acc.Visible = True
>
> Set db = acc.DBEngine.OpenDatabase(strDbName)
> acc.OpenCurrentDatabase strDbName
>
> 'open the Import Form
> acc.DoCmd.RunMacro strForm
>
> 'put value in the textbox
> acc.Forms.Import.pathspecification.Value = strTabDir
>
> 'move focus to OK button
> acc.Forms.Import.okbutton.SetFocus
>
> 'press Enter key/mouse click
> acc.Forms.Import.okbutton.SendKeys "{ENTER}"
>
date: Sat, 4 Oct 2008 11:49:25 +0400
author: Alex Dybenko
Re: Click button on form using VBscript
Alex,
Thanks for taking the time to reply. I neglected to mention that I am a
beginner. I didn't figure out the syntax to "call the ok_button proc", so I
just put the commands from the Sub ok_button into a MyFunction...
--
Public Function MyFunction()
Dim rcode As Integer
rcode = import_main()
End Function
--
This performs the desired import.
Thanks again,
Dan
"Alex Dybenko" wrote:
> Hi,
> you can make a public function, say MyFunction, in your form, which calls
> okbutton_click proc, and then you can run this function as
>
> acc.Forms.Import.MyFunction
>
>
> --
> Best regards,
> ___________
> Alex Dybenko (MVP)
> http://accessblog.net
> http://www.PointLtd.com
>
> "jdan" wrote in message
> news:55DFCA79-26B5-418A-A6EC-9E18FB427EF9@microsoft.com...
> > I want to use a VBscript to automate some tasks in Access 2003. The
> > database
> > has a macro to import data that I want to use. My script appears to work
> > up
> > to the last line. It opens the form "Import" in the database, inserts
> > "C\tmp\" into the textbox, then moves to the OK button. I have to press
> > the
> > Enter key on the keyboard or click the mouse manually for the script to
> > complete. How do I do automate this last step?
> >
> > I realize that Sendkeys isn't recommended, but I don't know any other way.
> > As shown now, it doesn't work.
> >
> > strTabDir = "C:\tmp\"
> > Set acc = createobject("Access.Application")
> >
> > acc.Visible = True
> >
> > Set db = acc.DBEngine.OpenDatabase(strDbName)
> > acc.OpenCurrentDatabase strDbName
> >
> > 'open the Import Form
> > acc.DoCmd.RunMacro strForm
> >
> > 'put value in the textbox
> > acc.Forms.Import.pathspecification.Value = strTabDir
> >
> > 'move focus to OK button
> > acc.Forms.Import.okbutton.SetFocus
> >
> > 'press Enter key/mouse click
> > acc.Forms.Import.okbutton.SendKeys "{ENTER}"
> >
date: Mon, 6 Oct 2008 10:49:02 -0700
author: jdan
|
|