Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
David P.
 
Posts: n/a
Default Opening a file in a macro (network)

I have a macro that requires opening a file in My Documents. This may be a
networking question that may require onsite help but what I was wondering is
if there is a way in the code to specify to open a file in My Documents from
"the computer you're on" for example (not sure how to word that). I'm trying
to avoid having to create a macro for each computer because I will have the
same file stored in My Documents on each computer. Does that make sense?

For example, the code right now reads (for the computer I am currently on -
"Blinds etc" is how the computer is named I believe & the other folders will
be exactly the same on the other computers ):

Workbooks.Open Filename:= _
"C:\Documents and Settings\BLINDS ETC\My Documents\Pricing\Company
Price Lists\Temporary.xls"

--
David P.
  #3   Report Post  
David P.
 
Posts: n/a
Default

Hello Nick,

The file is located on the computer that we treat as a server - which is not
the one I'm working on for example.

Is there a way to do this?(see what I have in quotes):

Workbooks.Open Filename:= _
"C:\Documents and Settings\"THIS COMPUTER"\My Documents\Pricing\Company
Price Lists\Temporary.xls"


--
David P.


"Nick Hodge" wrote:

David

Where will the file with the macro be?

If it's inside the username folder (at least) you will be able to get that
by looking at the Workbook.Fullname property and strip out the bits you
need.

You could also read and then parse the DefaultFilePath property of the
application. Some of these may be dangerous if the user moves the file or
changes the default file path

Just a couple of suggestions

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"David P." wrote in message
...
I have a macro that requires opening a file in My Documents. This may be a
networking question that may require onsite help but what I was wondering
is
if there is a way in the code to specify to open a file in My Documents
from
"the computer you're on" for example (not sure how to word that). I'm
trying
to avoid having to create a macro for each computer because I will have
the
same file stored in My Documents on each computer. Does that make sense?

For example, the code right now reads (for the computer I am currently
on -
"Blinds etc" is how the computer is named I believe & the other folders
will
be exactly the same on the other computers ):

Workbooks.Open Filename:= _
"C:\Documents and Settings\BLINDS ETC\My Documents\Pricing\Company
Price Lists\Temporary.xls"

--
David P.




  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

Are you saying you want to get to the "My documents" folder for the pc that
you're on?

Option Explicit
Sub testme()

Dim WSHShell As Object
Dim myDocPath As String

Set WSHShell = CreateObject("WScript.Shell")
myDocPath = WSHShell.SpecialFolders("mydocuments")

workbooks.open _
filename:=myDocPath & "\Pricing\Company Price Lists\Temporary.xls"

End Sub

Maybe???????


David P. wrote:

Hello Nick,

The file is located on the computer that we treat as a server - which is not
the one I'm working on for example.

Is there a way to do this?(see what I have in quotes):

Workbooks.Open Filename:= _
"C:\Documents and Settings\"THIS COMPUTER"\My Documents\Pricing\Company
Price Lists\Temporary.xls"


--
David P.

"Nick Hodge" wrote:

David

Where will the file with the macro be?

If it's inside the username folder (at least) you will be able to get that
by looking at the Workbook.Fullname property and strip out the bits you
need.

You could also read and then parse the DefaultFilePath property of the
application. Some of these may be dangerous if the user moves the file or
changes the default file path

Just a couple of suggestions

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"David P." wrote in message
...
I have a macro that requires opening a file in My Documents. This may be a
networking question that may require onsite help but what I was wondering
is
if there is a way in the code to specify to open a file in My Documents
from
"the computer you're on" for example (not sure how to word that). I'm
trying
to avoid having to create a macro for each computer because I will have
the
same file stored in My Documents on each computer. Does that make sense?

For example, the code right now reads (for the computer I am currently
on -
"Blinds etc" is how the computer is named I believe & the other folders
will
be exactly the same on the other computers ):

Workbooks.Open Filename:= _
"C:\Documents and Settings\BLINDS ETC\My Documents\Pricing\Company
Price Lists\Temporary.xls"

--
David P.





--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to save a file as ynissel Excel Discussion (Misc queries) 4 May 26th 05 02:48 PM
Opening a file with code without a set file name jenkinspat Excel Discussion (Misc queries) 1 March 3rd 05 03:40 PM
Opening a file with a Macro Adam1 Chicago Excel Discussion (Misc queries) 2 February 28th 05 10:13 PM
macro error when opening any file psp Excel Discussion (Misc queries) 1 January 31st 05 04:33 PM
After deleting a macro, I still get the pop-up when opening file Anne Excel Worksheet Functions 2 December 8th 04 05:31 PM


All times are GMT +1. The time now is 11:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"