WRQ Reflection/VBA programming

cshivers

New Member
Joined
Mar 1, 2010
Messages
34
Does anyone have any experience using VBA with WRQ Reflection? I have tried multiple searches related to WRQ Reflection and VBA with no luck on figureing out how to use VBA to access WRQ Reflection. I cant find how to even connect let alone start sending commands do and from. Right now i am just trying to establish a connection or anything. Any Help is appreciated. Thank you.
 
i have named my Sheet as yoursheet :D
so that i can execute the code :)
but its showing error as mentioned above
 
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
sorry missed an S in the code should have been...

LR = Workbooks(WbSource).WorkSheets("yoursheet").

you will need to change all instances of worksheet to worksheets
 
Upvote 0
still showing error at and is not able to find the Workbook ! object does not support this property or method And Highlights only the word "WorkBooks"
LR = Workbooks(WbSource).WorkSheets("yoursheet").Range("B65536").End(xlUp).Row 'FInd the last row
 
Upvote 0
this is straight out of the TNP help for VBE.....

GetObject Function Example

This example uses the GetObject function to get a reference to a specific Microsoft Excel worksheet (<CODE>MyXL</CODE>). It uses the worksheet's Application property to make Microsoft Excel visible, to close it, and so on. Using two API calls, the DetectExcel Sub procedure looks for Microsoft Excel, and if it is running, enters it in the Running Object Table. The first call to GetObject causes an error if Microsoft Excel isn't already running. In the example, the error causes the ExcelWasNotRunning flag to be set to True. The second call to GetObject specifies a file to open. If Microsoft Excel isn't already running, the second call starts it and returns a reference to the worksheet represented by the specified file, mytest.xls. The file must exist in the specified location; otherwise, the Visual Basic error Automation error is generated. Next the example code makes both Microsoft Excel and the window containing the specified worksheet visible. Finally, if there was no previous version of Microsoft Excel running, the code uses the Application object's Quit method to close Microsoft Excel. If the application was already running, no attempt is made to close it. The reference itself is released by setting it to Nothing.
Rich (BB code):
<CODE>' Declare necessary API routines:Declare Function FindWindow Lib "user32" Alias _"FindWindowA" (ByVal lpClassName as String, _ ByVal lpWindowName As Long) As LongDeclare Function SendMessage Lib "user32" Alias _"SendMessageA" (ByVal hWnd as Long,ByVal wMsg as Long, _ ByVal wParam as Long, _ ByVal lParam As Long) As LongSub GetExcel() Dim MyXL As Object ' Variable to hold reference ' to Microsoft Excel. Dim ExcelWasNotRunning As Boolean ' Flag for final release.' Test to see if there is a copy of Microsoft Excel already running. On Error Resume Next ' Defer error trapping.' Getobject function called without the first argument returns a ' reference to an instance of the application. If the application isn't' running, an error occurs. Set MyXL = Getobject(, "Excel.Application") If Err.Number <> 0 Then ExcelWasNotRunning = True Err.Clear ' Clear Err object in case error occurred.' Check for Microsoft Excel. If Microsoft Excel is running,' enter it into the Running Object table. DetectExcel' Set the object variable to reference the file you want to see. Set MyXL = Getobject("c:\vb4\MYTEST.XLS")' Show Microsoft Excel through its Application property. Then' show the actual window containing the file using the Windows' collection of the MyXL object reference. MyXL.Application.Visible = True MyXL.Parent.Windows(1).Visible = True Do manipulations of your file here. ' ...' If this copy of Microsoft Excel was not running when you' started, close it using the Application property's Quit method.' Note that when you try to quit Microsoft Excel, the' title bar blinks and a message is displayed asking if you' want to save any loaded files. If ExcelWasNotRunning = True Then MyXL.Application.Quit End IF Set MyXL = Nothing ' Release reference to the ' application and spreadsheet.End SubSub DetectExcel()' Procedure dectects a running Excel and registers it. Const WM_USER = 1024 Dim hWnd As Long' If Excel is running this API call returns its handle. hWnd = FindWindow("XLMAIN", 0) If hWnd = 0 Then ' 0 means Excel not running. Exit Sub Else ' Excel is running so use the SendMessage API ' function to enter it in the Running Object Table. SendMessage hWnd, WM_USER + 18, 0, 0 End IfEnd Sub
</CODE>


</PRE>
 
Upvote 0
while in your tnp session, click on F11, when the VBE window comes up, click on F2 this should open your object browser, this will allow you to search for the GetObject command, then right click on this command and click on help......
 
Upvote 0
sorry for the late reply forum of out of service
well excel was already running !...but it is not able to find the sheet ! this due to which the loop is not working
the Coding that you gave is like this

Code:
' Declare necessary API routines:Declare Function FindWindow Lib "user32" Alias _"FindWindowA" (ByVal lpClassName as String, _ ByVal lpWindowName As Long) As LongDeclare Function SendMessage Lib "user32" Alias _"SendMessageA" (ByVal hWnd as Long,ByVal wMsg as Long, _ ByVal wParam as Long, _ ByVal lParam As Long) As LongSub GetExcel()
Dim MyXL As Object ' Variable to hold reference ' to Microsoft Excel. 
Dim ExcelWasNotRunning As Boolean ' Flag for final release.
' Test to see if there is a copy of Microsoft Excel already running.
On Error Resume Next ' Defer error trapping.
' Getobject function called without the first argument returns a
' reference to an instance of the application.
 If the application isn't' running, an error occurs.
Set MyXL = Getobject(, "Excel.Application") 
If Err.Number <> 0 Then ExcelWasNotRunning = True
Err.Clear ' Clear Err object in case error occurred.
' Check for Microsoft Excel.
If Microsoft Excel is running,' enter it into the Running Object table.
.DetectExcel' Set the object variable to reference the file you want to see
. Set MyXL = Getobject("c:\vb4\MYTEST.XLS")' Show Microsoft Excel through its Application property. 
Then' show the actual window containing the file using the Windows' collection of the MyXL object reference
. MyXL.Application.Visible = True 
MyXL.Parent.Windows(1).Visible = True
Do manipulations of your file here. ' ...' If this copy of Microsoft Excel was not running when you'
started, close it using the Application property's Quit method.' Note that when you try to quit Microsoft Excel, the
' title bar blinks and a message is displayed asking if you
' want to save any loaded files
. If ExcelWasNotRunning = True 
Then MyXL.Application.Quit 
End
IF Set MyXL = Nothing ' Release reference to the
' application and spreadsheet.End 
Sub
Sub 
DetectExcel()' Procedure dectects a running Excel and registers it
. Const WM_USER = 1024 
Dim hWnd As Long' If Excel is running this API call returns its handle
. hWnd = FindWindow("XLMAIN", 0) 
If hWnd = 0 
Then ' 0 means Excel not running.
 Exit Sub 
Else ' Excel is running so use the SendMessage API ' function to enter it in the Running Object Table
. SendMessage hWnd, WM_USER + 18, 0, 0 
End If
End Sub
 
Upvote 0
This has been confusing me for two weeks.
I keep seeing user posting code for connecting such as what cshivers did. Next I see users explaining how to use session.

I know that session is the top level object.

I can use VBScript or Excel.

Say I create a connection. How does session know that the connection is available? Does the IDE become aware of Session once the .connection is made?

Thanks,

Kevin
 
Upvote 0

Forum statistics

Threads
1,223,708
Messages
6,174,006
Members
452,542
Latest member
Bricklin

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