Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Help with workbook path

Hi

I need to specify the path of the ActiveWorkbook so that it can be used
later in my code.

I have tried something like "ActiveWorkbook = ActiveWorkbook.Path" but I'm
only guessing, can anyone help with the correct code please.

--
Kind Regards

Mick


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help with workbook path

Dim sPath as String
sPath = ActiveWorkbook.Path
msgbox sPath

sPath will then hold a string that contains the activeworkbook path.

If by specify, you mean you are trying to change it, that can only be done
with a SaveAs .

--
Regards,
Tom Ogilvy



"Grandad" wrote in message
...
Hi

I need to specify the path of the ActiveWorkbook so that it can be used
later in my code.

I have tried something like "ActiveWorkbook = ActiveWorkbook.Path" but I'm
only guessing, can anyone help with the correct code please.

--
Kind Regards

Mick




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Help with workbook path

ActiveWorkbook.FullName

I agree it should be Path, but there we are.

--

HTH

RP

"Grandad" wrote in message
...
Hi

I need to specify the path of the ActiveWorkbook so that it can be used
later in my code.

I have tried something like "ActiveWorkbook = ActiveWorkbook.Path" but I'm
only guessing, can anyone help with the correct code please.

--
Kind Regards

Mick




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Help with workbook path

I read your question as getting the workbook name, but seeing Tom's response
as re-reading your question, I am probably wrong.

As Tom says, both Path and Fullname are string properties, so you cannot set
the workbook to them (why would you want to?)

What you can do is save in a variable

myWbString = Activeworkbook.Path (or Fullname)


--

HTH

RP

"Bob Phillips" wrote in message
...
ActiveWorkbook.FullName

I agree it should be Path, but there we are.

--

HTH

RP

"Grandad" wrote in message
...
Hi

I need to specify the path of the ActiveWorkbook so that it can be used
later in my code.

I have tried something like "ActiveWorkbook = ActiveWorkbook.Path" but

I'm
only guessing, can anyone help with the correct code please.

--
Kind Regards

Mick






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Help with workbook path

Guys

Thanks for the info. This works OK when I open the workbook as a template,
as it already has a "Saved" path. However, if I open as new document from
the template, as it has not been previously saved does not have a path. I
know I could save it then, but the default location is different on most of
the PCs that need to use the file. The folder structure is the same on all
PCs but they start from different drive letters. Is there a way to overcome
this?

Thanks for all your help.
Mick

"Tom Ogilvy" wrote in message
...
Dim sPath as String
sPath = ActiveWorkbook.Path
msgbox sPath

sPath will then hold a string that contains the activeworkbook path.

If by specify, you mean you are trying to change it, that can only be done
with a SaveAs .

--
Regards,
Tom Ogilvy



"Grandad" wrote in message
...
Hi

I need to specify the path of the ActiveWorkbook so that it can be used
later in my code.

I have tried something like "ActiveWorkbook = ActiveWorkbook.Path" but
I'm
only guessing, can anyone help with the correct code please.

--
Kind Regards

Mick








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help with workbook path

When a file is opened using New and specifying a template, then there is no
link established between the new file (which as you say, until saved has no
path) and the template.

You can get the drive letter for the Excel application with

Left(Application.path,1)

or the path with

sPath = Application.Path

you can get the drive letter and current default directory with

sPath = Curdir

? curdir
C:\Documents and Settings\togilvy\My Documents

You can use the scripting runtime to identify drives and examine directories
or use the Window API.

Perhaps from the above, you can formulate a strategy to identify the
location (find a drive that has a path of

<d:\myfolders\back or \mydata directory below the folder with the excel
application as examples) and someone can give you the specific code you
need.

--
Regards,
Tom Ogilvy

"Grandad" wrote in message
...
Guys

Thanks for the info. This works OK when I open the workbook as a

template,
as it already has a "Saved" path. However, if I open as new document from
the template, as it has not been previously saved does not have a path. I
know I could save it then, but the default location is different on most

of
the PCs that need to use the file. The folder structure is the same on

all
PCs but they start from different drive letters. Is there a way to

overcome
this?

Thanks for all your help.
Mick

"Tom Ogilvy" wrote in message
...
Dim sPath as String
sPath = ActiveWorkbook.Path
msgbox sPath

sPath will then hold a string that contains the activeworkbook path.

If by specify, you mean you are trying to change it, that can only be

done
with a SaveAs .

--
Regards,
Tom Ogilvy



"Grandad" wrote in message
...
Hi

I need to specify the path of the ActiveWorkbook so that it can be used
later in my code.

I have tried something like "ActiveWorkbook = ActiveWorkbook.Path" but
I'm
only guessing, can anyone help with the correct code please.

--
Kind Regards

Mick








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
New Workbook Path exceluserforeman Excel Discussion (Misc queries) 2 December 7th 05 12:10 AM
Workbook path nc Excel Discussion (Misc queries) 2 April 4th 05 03:37 PM
path of workbook fabalicious[_8_] Excel Programming 8 April 16th 04 05:27 PM
Workbook Path Todd Huttenstine[_2_] Excel Programming 5 December 27th 03 10:02 AM
Path where Workbook is saved Todd Huttenstine[_2_] Excel Programming 3 December 2nd 03 01:50 AM


All times are GMT +1. The time now is 07:13 PM.

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"