VBA macro for Host Explorer

scottleger4

New Member
Joined
Oct 3, 2016
Messages
41
Office Version
  1. 365
Platform
  1. Windows
I'm trying to modify an existing macro that interacts with Host Explorer to essentially reset a connection prior to executing the remainder of the macro. Manually, I would do this action by pressing, in sequence individually, "ALT - F - D - ALT - F - T" as these are the keystrokes/hotkeys to "disconnect" and "connect". Borrowing some code from a different working macro I thought it would be as easy as...

Dim MyHost As Object
Dim HE As Object
Set HE = CreateObject("HostExplorer")
Set MyHost = HE.CurrentHost
Dim RC As Integer

RC = MyHost.Runcmd("ALT")
RC = MyHost.keys("F")
RC = MyHost.keys("D")
RC = MyHost.Runcmd("ALT")
RC = MyHost.keys("F")
RC = MyHost.keys("T")

...but that doesn't work as I expected. How would I write this macro to essentially simulate specific key strokes to accomplish the same thing as I do manually on my keyboard? Thanks in advance.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,223,896
Messages
6,175,263
Members
452,627
Latest member
KitkatToby

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