PC Review


Reply
Thread Tools Rate Thread

Constant as network drive

 
 
Merlynsdad
Guest
Posts: n/a
 
      16th Oct 2009
I have an Excel file which needs to access another Excel file on a network. I
want to write the filename as a constant. This works fine when the constant
refers to a file on my local drive, but if the constant refers to a network
drive, when the code gets to "Windows (constant).Activate" it fails. How do I
get this to refer to a file on a network drive?
 
Reply With Quote
 
 
 
 
JP
Guest
Posts: n/a
 
      16th Oct 2009
Use the UNC path instead.

See http://www.dailydoseofexcel.com/arch...6/21/unc-path/ and
scroll down to the first comment for sample code.

--JP

On Oct 16, 11:49*am, Merlynsdad <Merlyns...@discussions.microsoft.com>
wrote:
> I have an Excel file which needs to access another Excel file on a network. I
> want to write the filename as a constant. This works fine when the constant
> refers to a file *on my local drive, but if the constant refers to a network
> drive, when the code gets to "Windows (constant).Activate" it fails. How do I
> get this to refer to a file on a network drive?


 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      16th Oct 2009
Windows(something).activate
doesn't depend on the path--mapped or UNC.

You only use the filename (Book1.xls, not c:\my documents\excel\book1.xls).

Ps.

I try my best to not use the windows collection. I'll go through the workbooks
collection. And if my code opens the workbook:

Dim wkbk as workbook
set wkbk = workbooks.open(filename:=somefilenamehere)
....
I can use:
wkbk.activate

But be aware that most things can be done without activating or selecting.

Merlynsdad wrote:
>
> I have an Excel file which needs to access another Excel file on a network. I
> want to write the filename as a constant. This works fine when the constant
> refers to a file on my local drive, but if the constant refers to a network
> drive, when the code gets to "Windows (constant).Activate" it fails. How do I
> get this to refer to a file on a network drive?


--

Dave Peterson
 
Reply With Quote
 
Gary Brown
Guest
Posts: n/a
 
      16th Oct 2009
Try
Application.Workbooks.Open(constant)

--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown



"Merlynsdad" wrote:

> I have an Excel file which needs to access another Excel file on a network. I
> want to write the filename as a constant. This works fine when the constant
> refers to a file on my local drive, but if the constant refers to a network
> drive, when the code gets to "Windows (constant).Activate" it fails. How do I
> get this to refer to a file on a network drive?

 
Reply With Quote
 
Merlynsdad
Guest
Posts: n/a
 
      16th Oct 2009
It helps in a way but it brings up another problem. In designing this project
the spreadsheet that I'm using as a database has always been open first. The
Application.Workbooks.Open(constant) does open that database, but my list
boxes in the current workbook that are based on that database don't populate
when it opens. The AutoLoad property is set to True. How do I get them to
populate?

"Gary Brown" wrote:

> Try
> Application.Workbooks.Open(constant)
>
> --
> Hope this helps.
> If it does, please click the Yes button.
> Thanks in advance for your feedback.
> Gary Brown
>
>
>
> "Merlynsdad" wrote:
>
> > I have an Excel file which needs to access another Excel file on a network. I
> > want to write the filename as a constant. This works fine when the constant
> > refers to a file on my local drive, but if the constant refers to a network
> > drive, when the code gets to "Windows (constant).Activate" it fails. How do I
> > get this to refer to a file on a network drive?

 
Reply With Quote
 
Adam
Guest
Posts: n/a
 
      16th Oct 2009
Maybe try this command before the open command:

ActiveWorkbook.UpdateLink Name:= _
"(database address.xls)", Type:=xlExcelLinks

Not quite sure how excel dropdown boxes obtain their data, i.e. from another
spreadsheet, but maybe that would work?



"Merlynsdad" wrote:

> It helps in a way but it brings up another problem. In designing this project
> the spreadsheet that I'm using as a database has always been open first. The
> Application.Workbooks.Open(constant) does open that database, but my list
> boxes in the current workbook that are based on that database don't populate
> when it opens. The AutoLoad property is set to True. How do I get them to
> populate?
>
> "Gary Brown" wrote:
>
> > Try
> > Application.Workbooks.Open(constant)
> >
> > --
> > Hope this helps.
> > If it does, please click the Yes button.
> > Thanks in advance for your feedback.
> > Gary Brown
> >
> >
> >
> > "Merlynsdad" wrote:
> >
> > > I have an Excel file which needs to access another Excel file on a network. I
> > > want to write the filename as a constant. This works fine when the constant
> > > refers to a file on my local drive, but if the constant refers to a network
> > > drive, when the code gets to "Windows (constant).Activate" it fails. How do I
> > > get this to refer to a file on a network drive?

 
Reply With Quote
 
Gary Brown
Guest
Posts: n/a
 
      16th Oct 2009
If the Excel workbook on the network is already open, simply refer to it by
it's workbook name.
Example:
constant = "MyWorkbookOnTheNetwork.xls"
Windows(constant).Activate

It just worked for me in a quick test.

--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown



"Merlynsdad" wrote:

> It helps in a way but it brings up another problem. In designing this project
> the spreadsheet that I'm using as a database has always been open first. The
> Application.Workbooks.Open(constant) does open that database, but my list
> boxes in the current workbook that are based on that database don't populate
> when it opens. The AutoLoad property is set to True. How do I get them to
> populate?
>
> "Gary Brown" wrote:
>
> > Try
> > Application.Workbooks.Open(constant)
> >
> > --
> > Hope this helps.
> > If it does, please click the Yes button.
> > Thanks in advance for your feedback.
> > Gary Brown
> >
> >
> >
> > "Merlynsdad" wrote:
> >
> > > I have an Excel file which needs to access another Excel file on a network. I
> > > want to write the filename as a constant. This works fine when the constant
> > > refers to a file on my local drive, but if the constant refers to a network
> > > drive, when the code gets to "Windows (constant).Activate" it fails. How do I
> > > get this to refer to a file on a network drive?

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: constant network activity Tim Meddick Windows XP General 0 20th Nov 2010 05:47 PM
Re: constant network activity Paul Windows XP General 0 19th Nov 2010 10:46 PM
Constant network access prsimmonds Windows Vista General Discussion 3 23rd Dec 2007 04:21 PM
constant 'acquiring network address' jungsook.yang Windows XP General 1 6th Feb 2007 05:55 AM
constant beeping w/ new cd drive =?Utf-8?B?YmFzaWM=?= Windows XP Hardware 1 23rd May 2004 06:36 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:42 AM.