Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with CreateObject

Status
Not open for further replies.

QAQ

Programmer
Nov 28, 2006
7
GB
Hi all :),
Im using the following piece of code in MS Excel:

' Declare an object variable to hold the object
' reference. Dim as Object causes late binding.
Dim ExcelSheet As Object
Set ExcelSheet = CreateObject("Excel.Sheet", "RB-COMPUTER")
' Make Excel visible through the Application object.
ExcelSheet.Application.Visible = True
' Place some text in the first cell of the sheet.
ExcelSheet.Application.Cells(1, 1).Value = "This is column A, row 1"
' Save the sheet to C:\test.xls directory.
ExcelSheet.SaveAs "C:\TEST.XLS"
' Close Excel with the Quit method on the Application object.
ExcelSheet.Application.Quit
' Release the object variable.
Set ExcelSheet = Nothing

...Which you can tell is straight out of the help file.

The problem is that I get an error on the following line of code:

Set ExcelSheet = CreateObject("Excel.Sheet", "RB-COMPUTER")

The error reads: "Run time error '462'. The remote server machine does not exist or is unavailable"

Now, I have a network setup between my PC and the other PC called "RB-COMPUTER".

Where am i going wrong? Please help.
 




Hi.

"The problem is that I get an error on the following line of code:

Set ExcelSheet = CreateObject("Excel.Sheet", "RB-COMPUTER")"

Well seems you cheated a bit. The example is in regard to "the version number of an instance of Excel running on a remote computer named MyServer:"

The key phrase thus emphasized...
Code:
Dim xlApp As Object
Set xlApp = CreateObject("Excel.[b]Application[/b]", "RB-COMPUTER")"



Skip,
[sub]
[glasses] When a wee mystic is on the loose..
It's a Small Medium at Large! [tongue][/sub]
 
Hi SkipVought,
Thanks for the reply. I tried your code and it still doesnt work - the same error comes up. The PC I am running the code from has windows vista and the other pc (rb-computer) has windows xp. Previously the windows vista pc used to have xp on it. and even then it never ran.

Can someone help please?

Thanks
Regards

Q
 




This seems like the kind of thing that you're going to have to experiment with persistently to discover a solution.

No one else has your environment.

However, you may be lucky and get a reply some guru.

Skip,
[sub]
[glasses] When a wee mystic is on the loose..
It's a Small Medium at Large! [tongue][/sub]
 
QAQ,
The following refers to VB 6 specifically, but since VBA/VBScript are variants of...

MSDN said:
The documentation for the CreateObject function does not mention that the server referenced in the servername argument must be a Windows NT or Windows 2000 server.
CMP
 
Thank You CMP! That explains a lot!
 
So...is there another function that does the the same thing ... or is there another way around to do the same thing?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top