Accessing to a network

November 2, 2009 at 11:02:35
Specs: Windows XP
I am trying to open files in VB. The files are read only and located on the network. I am using this code ret = Shell("C:\Program Files\AutoCAD 2008\acad.exe - open directory", vbMaximizedFocus) The problem is when autocad opens it can't get an access to the network. What can I do to make this work? Do I have to add code that lets autocad access to the network drive then make it open the file?
any help is appriciated

See More: Accessing to a network

Report •

November 2, 2009 at 23:03:03
what are you feediing it for "directory" : network drive as in H:\test"? or \\computername\\test etc. I use Vb, but haven't yet used it much for network operations, so not much help.
also: unknown for me is what command-line
parms acad accepts: " - open directory" ?
is unknown to me but this prob'ly something you know that i don't. usually its something like: acad F:\TEST\FILE1 for commandlines input of file-to-open.
ps: i think the vbMaxFocus needs to be outside the parentheses. My old vb (32) help told me wrong and i had to find out the hard way. unless it has changed, it should be something like:
shell ("..\acad testfil .."),vbMaximizedFocus
(or whatever the constant is. That value (0,1,
2 etc.) for vbWindowstyle should be outside the (). good luc

Report •

November 3, 2009 at 18:46:03
the value of directory looks like "H:\blah\blah\blah\filename.dwg" after evaluating
so with the mentioned above code should open autocad and open the "filename" drawing. but it doesn't.
message pops up saying make sure you have access to the network. I use this network directory all the time. it has all the read only files. so i am wondering if i have to add a code to map to the network with the code first and then try to access to the file. if so how can this be done.

in you comment for maximizefocus, it works for me for the drawings that i have on my local drive. i have not tried it outside of the parenthesis yet. i will try it and give u a feed back when i can.

Report •

November 5, 2009 at 08:10:16
korhaniski: "C:\Program Files\AutoCAD 2008\acad.exe - open directory"
I don't know what you're tying to do here, nor can I find any information in Google about opening a directory in autoCAD. Do you have some sort of reference link?

korhaniski: it can't get an access to the network
What happens when you try?

Show us the entire function.

nbrane: i think the vbMaxFocus needs to be outside the parentheses.
He's getting a return value. Parentheses around all of the arguments.

Report •

Related Solutions

November 5, 2009 at 17:53:19
Razor, yeh you're right, i forget about the return-value version of api's is inside (). my bad and apologies for my dumbhead.

Ooooh, i see, i think, " - open directory" is an acad
commandline argument.
My vb will open a file on a mapped drive without any extra code, but that only applies to vb (as in "open H:\dahdah for input as #1" etc). It seems like the problem might be with acad, if it doesn't recognize network-drive mapping. if that's the case, might read up on acad's documentation to see if there's a setting in that application. I would think it's done all the time, so there should be a setting. only thing else i know to try is appactivate acad's window and sendkeys alt-f,o,filename:
Appactivate "Autocad -",1 (or whatever wintitle acad puts up). do shell acad without commandline argument.

Shell("C:\Program Files\AutoCAD 2008\acad.exe",1)
' 3-sec delay here for program to open:
Sleep 3000
sendkeys "%f",true
sendkeys "o",true
sendkeys "H:\acadfiles\drawing3",true (or whatever)
senkeys "{ENTER}",true

this way, windows is maybe doing the open-op and not acad
sorry for my wrong info and not being more help.

Report •

November 6, 2009 at 10:02:36
ahh crap the program stopped working and i forgot what i did right...

ok nbrane I added to code you indicated into the vba code within excel. it indicates sub or function not defined. Since i am relitivly new at this I am confused. I think with what you are doing it should work, but i gotta figure out how to fix this compile error. I'll do some searching. If you know how to fix that problem let me know please thanks.
my code currently looks like this to open an autocad file on a network using excel.
directory = "S:\Data\xxx\xxx\" + xxxfolder + "\" + fileNumber + fileType
ret = Shell("C:\Program Files\AutoCAD 2008\acad.exe ", vbMaximizedFocus)

sleep 3000
SendKeys "%f", True
SendKeys "o", True
senkeys directory, True
SendKeys "{ENTER}", True

I allow the user to enter their file number and let them chose what type of file it is. Depending on that I make some string manuplations to figure out "xxxfolder" and "filename" and "filetype". when i debug the value of directory points to the right spot.

basicly my goal is to let user enter their file name and click button and the drawing opens up in autocad.
thanks and any help is appriciated

Report •

November 6, 2009 at 12:27:17
finally found the solution... it wasn't a network issue... i wasn't doing it right. here is a function that does it

Sub AbreDesenho(Arquivo As String)
Dim AcadApp As Object, acadDoc As Object

On Error Resume Next
'test for existent cad application
Set AcadApp = GetObject(, "AutoCAD.Application")
If Err Then
'opens a new application if none is available
Set AcadApp = CreateObject("AutoCAD.Application")
If Err Then
MsgBox "Error opening AutoCAD"
Exit Sub
End If
End If
AcadApp.WindowState = acMax 'acMax
Set acadDoc = AcadApp.Documents.Open(Arquivo)
AcadApp.Application.Visible = True

'limpo variƔveis

End Sub

Report •

Ask Question