Reflections WRQ VBA

Robertson1995

Board Regular
Joined
Apr 1, 2009
Messages
117
I have the following code that I use in WRQ Reflections. It is very basic and runs the command bts_status mc800bts877. The characters "877" which are in red below is a site # which changes. What I need is for the macro to run the command bts_status mc800bts and then have an inputbox ask for the next 3 characters (in this example 877) that then carriage return after ok is selected on the input box. Thanks.


Sub Macro1()
' Generated by the Reflection Macro Recorder on 04-22-2009 09:01:25.57.
' Generated by Reflection for UNIX and Digital 8.0.6.
On Error GoTo ErrorHandler
Const NEVER_TIME_OUT = 0
Dim CR As String ' Chr$(rcCR) = Chr$(13) = Control-M
Dim ESC As String ' Chr$(rcESC) = Chr$(27) = Control-[
CR = Chr$(rcCR)
ESC = Chr$(rcESC)
With Session
.Transmit "bts_status mc800bts877" & CR
' .WaitForString ESC & "[K", NEVER_TIME_OUT, rcAllowKeystrokes
Exit Sub
ErrorHandler:
.MsgBox Err.Description, vbExclamation + vbOKOnly
End With
' Recording stopped at 09:04:44.83.
End Sub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Maybe try:

Code:
Sub Macro1()
' Generated by the Reflection Macro Recorder on 04-22-2009 09:01:25.57.
' Generated by Reflection for UNIX and Digital 8.0.6.
On Error GoTo ErrorHandler
ibValue = inputbox("Enter Site Number")
Const NEVER_TIME_OUT = 0
Dim CR As String ' Chr$(rcCR) = Chr$(13) = Control-M
Dim ESC As String ' Chr$(rcESC) = Chr$(27) = Control-[
CR = Chr$(rcCR)
ESC = Chr$(rcESC)
With Session
.Transmit "bts_status mc800bts" & ibValue & CR
' .WaitForString ESC & "[K", NEVER_TIME_OUT, rcAllowKeystrokes
Exit Sub
ErrorHandler:
.MsgBox Err.Description, vbExclamation + vbOKOnly
End With
' Recording stopped at 09:04:44.83.
End Sub
You could probably limit the inout to integers if that is what will always be entered or create a loop to make sure a value is entered, but this should get you started.

Hope that helps.
 
Upvote 0
It's working. Thanks for your help. There is another thing I would like to do with this a similar command using a Userform. I am new to userforms and I am trying to learn VBA, so I may not be asking this question correctly, but let me try.

I have built a macro using the answer from your reply and here's the command it runs:

1. cd 0%:cbs1:cells1:mc800bts (no carriage return)
2. After the above command is listed at the prompt, the inputbox pops up and asks for the site number which results in cd 0%:cbs1:cells:mc800bts600.
3. then the text :mcBTSSubsystem1:Root1: is added resulting in this command:

0%:cbs1:cells:mc800bts600:mcBTSSubsystem1:Root1:

It is working great up to this point.

Now from this point the command requires that we enter either CEM1, CEM2, or CEM3. I would like for a user form to popup with these 3 options on it and whichever one I choose it would run. For example if I click CEM1 on the userform it would run the following command:

0%:cbs1:cells:mc800bts600:mcBTSSubsystem1:Root1:CEM1;

Hope this makes sense. Being new to userforms, I may not even be building the macro in the form correctly.
 
Last edited:
Upvote 0
Yes, you would be correct in using a userform. I have not done a userform or really that much coding at all in reflections to know the code to well. But I would say it should be a pretty simple userform that contains 3 buttons.

Then within the code for the 3 buttons, you could have it run the command based on CEM 1, 2 or 3.

It shouldn't be that hard of a task to accomplish, but if you need some help with the code after getting the userform setup and setting up some on click events I think is what you would want to. Something like this with a userform with 3 buttons:

Code:
Private Sub CommandButton1_Click()
'Call 1st code
End Sub
 
Private Sub CommandButton2_Click()
'Call 2nd code
End Sub
 
Private Sub CommandButton3_Click()
'Call 3rd code
End Sub
You would just call the module that you have building the string and then add CEM1 or whichever to the end of the sreing depending on the button they pushed.

Hope that helps and post back with any other questions and the complete code as you have it, if you need more help.
 
Upvote 0
I too code in Reflection VBA,

Does anyone know how to open a file dialog box in reflection VBA, i can't seem to do it...????:confused:
 
Upvote 0
This is what I use to open a file dialog box and let them choose an excel 2007 file, you can adjust it for different file types:

Code:
Set oXLApp = New Excel.Application  'Create a new instance of Excel
strBook = oXLApp.GetOpenFilename(FileFilter:="Excel Files (*.xlsx),*.xlsx", Title:="Open a File", MultiSelect:=False)
If Len(strBook) < 6 Then Exit Sub
Set oXLBook = oXLApp.Workbooks.Open(strBook) 'Open an existing workbook
Hope that helps.
 
Upvote 0
This is what I use to open a file dialog box and let them choose an excel 2007 file, you can adjust it for different file types:

Code:
Set oXLApp = New Excel.Application  'Create a new instance of Excel
strBook = oXLApp.GetOpenFilename(FileFilter:="Excel Files (*.xlsx),*.xlsx", Title:="Open a File", MultiSelect:=False)
If Len(strBook) < 6 Then Exit Sub
Set oXLBook = oXLApp.Workbooks.Open(strBook) 'Open an existing workbook
Hope that helps.

schielrn, you're a lifesaver. works perfectly!
 
Upvote 0
This is what I use to open a file dialog box and let them choose an excel 2007 file, you can adjust it for different file types:

Code:
Set oXLApp = New Excel.Application  'Create a new instance of Excel
strBook = oXLApp.GetOpenFilename(FileFilter:="Excel Files (*.xlsx),*.xlsx", Title:="Open a File", MultiSelect:=False)
If Len(strBook) < 6 Then Exit Sub
Set oXLBook = oXLApp.Workbooks.Open(strBook) 'Open an existing workbook
Hope that helps.

Hi schielrn,

Is it possible to default to a certain directory when the file dialog box opens?
 
Upvote 0
Also just so you know this will not make the workbook visible after it is opened, it will leave it behind the scenes which is what I do for a lot of work, but this will make the aopplication visible:

Code:
oXLApp.Visible = True               'Show it to the user
Hope that helps.
 
Upvote 0
Hi schielrn,

Is it possible to default to a certain directory when the file dialog box opens?
It is probably possible, but I don't think so using getopenfilename. I think you'd have to use another approach for opening a file and I don't have time at the moment to research that. Maybe someone else will come along and know the command.
 
Upvote 0

Forum statistics

Threads
1,215,404
Messages
6,124,715
Members
449,184
Latest member
COrmerod

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