Option Explicit
'API Declaration
Public AcadApp As AcadApplication
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Const MOUSEEVENTF_RIGHTDOWN As Long = &H8
Private Const MOUSEEVENTF_RIGHTUP As Long = &H10
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub Civil3D_Create_Catchment()
Call Catchment
'Application.Visible = False
Dim i As Integer
With Prog_bar
'SET MIN value to 0
.ProgressBar1.Min = 0
'SET Max value as per your requirement
.ProgressBar1.Max = 15000
.Show vbModeless
'.ScrollBars = fmScrollBarsVertical
' run a loop to display progres bar
For i = 1 To 15000
'change the value of progress bar to show the progress using fill color
.ProgressBar1.Value = i
' chnage the caption of user form to display the percentage of task completed
.Caption = VBA.Format(i / Prog_bar.ProgressBar1.Max, "0%") & " Complete"
DoEvents ' DoEvents allows the UserForm to update.
Next
End With
' task finish unload progress bar
Unload Prog_bar
'Application.Visible = True
' Place Macro to Run After Count Down
Call Catchment_Storm_SendKeys
End Sub
Sub Catchment()
On Error Resume Next
Set AcadApp = GetObject(, "AutoCAD.Application")
If Err Then
Err.Clear
Set AcadApp = CreateObject("AutoCAD.Application")
End If
AppActivate AcadApp.Caption
AcadApp.Visible = True
AcadApp.Application.WindowState = acNorm
AcadApp.ActiveSpace = acModelSpace
If AcadApp.Documents.Count = 0 Then
AcadApp.Documents.Add
End If
AcadApp.ActiveDocument.SendCommand "_CREATECATCHMENTFROMOBJECT" & vbCr
End Sub
Sub Catchment_Storm_SendKeys()
Dim myApp As String
DoEvents
Application.Wait (Now + TimeValue("0:00:01"))
Sleep 250
SendKeys "{TAB}{TAB}{TAB}{TAB}", True
Sleep 250
SendKeys "{ENTER}", True
Sleep 250
SendKeys "{TAB}{TAB}{TAB}{TAB}", True
Sleep 250
SendKeys "{ENTER}", True
Sleep 250
SendKeys "{C}{_}{D}", True
Sleep 250
SendKeys "{TAB}", True
Sleep 250
SendKeys "{ENTER}", True
Sleep 250
SendKeys "{TAB}{TAB}{TAB}", True
Sleep 250
SendKeys "{ENTER}", True
Sleep 250
SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}", True
Sleep 250
SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}", True
Sleep 250
SendKeys "{DOWN}{RIGHT}{DOWN}{TAB}", True
Sleep 250
SendKeys "{5}", True
Sleep 250
SendKeys ("{/}"), True
Sleep 250
SendKeys "{6}", True
Sleep 250
SendKeys "{0}", True
Sleep 250
SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}", True
Sleep 250
SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}", True
Sleep 250
SendKeys "{TAB}{TAB}{TAB}{TAB}{TAB}", True
Sleep 250
SendKeys "{ENTER}", True
End Sub