Help with CreateObject

Q

Q

Hi all ,
I have two PCs on a network - one with windows vista and another with
windows xp operating system. I dont know much about networks and all i
know is that if i go to 'Network' on my windows vista taskbar - then i
can see 'Netgear DG834GT Router' and 'Rashid-PC' (the pc with vista)
and 'ROB-COMPUTER' (the pc with windows xp). I dont know how the
network was setup but it has something to do with the modem (Netgear
DG834GT Router) being connected to both PCs via wires (the router is
used for connecting to the internet). When i open the ROB-COMPUTER
from the Network window - all i see is the 'Printer' Icon, 'Printers'
Icon, 'SharedDocs' Icon, C drive and D drive..

Im a coding in Excel 2007 and on the PC with windows vista. Basically
I am trying the following code but its not working:

' Declare an object variable to hold the object
' reference. Dim as Object causes late binding.
Dim ExcelSheet As Object
Set ExcelSheet = CreateObject("Excel. Sheet", "ROB-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


I get the following error "Run-time error '462'. The remote server
machine does not exist or is not available." on the following line of
code:

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

Can someone help please?

Many Thanks :D

Regards

Q
 
K

Kevin B

Try declaring Excel as an application object and the the sheet as an object
of the application

********************************************
Dim xl As Excel.Application
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet

Set xl = CreateObject("Excel.Application")
Set wb = xl.Workbooks.Add
Set ws = wb.ActiveSheet

ws.Range("A1").Value = "Yada, yada, yada Warden..."
wb.SaveAs "C:\ParkThisFileHere\Yada.xls"
xl.Quit

********************************************
Also click on REFERENCES while in the VBE and verify that you have the
correct Excel reference library available.
 
Q

Q

OK. Thanks for that. I get the same error though. I've done something
else. I turned off the firewall on the PC with Win XP. Now i get a
different error: "Run-time error '70', Premission Denied."

Any ideas?
 
K

Kevin B

The Microsoft Knowledge Base article Article ID : 257757 has some information
regarding your error, which I assume is being generated on the server end of
things.

Perhaps this will be of assistance.

Good luck...
 
J

Jon Peltier

What are you trying to do? What's the network and router have to do with
creating an Excel worksheet?

- Jon
 
J

Jon Peltier

You're trying to instantiate Excel on the remote computer, or run Excel on
the local computer using the copy of Excel on the remote hard drive?

Yikes. I don't believe the first is possible, at least not without using
other specialized software. The second would be lacking all that neat
registry stuff that makes things work.

- Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top