473,385 Members | 1,564 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

(Workbooks.Open) with code on shared drives with different lettering in name

atljpe
11
I'm a beginner:
In MS Excel, my code begins with opening a file located within a shared file & drive. My drive begins with the letter "N" ie. N:\ftwntfilp012 where as other users may give it a different letter such as "Z" ie. Z:\ftwntfilp012.
Is there a way to use this code without having to change the lettering each time someone with a different letter before their drive uses this macro?
I hope I'm clear
Thanks for any assistance
atljpe

Expand|Select|Wrap|Line Numbers
  1. ..Sub NEWSEND()
  2. ActiveWorkbook.Save
  3. 'sub openup()
  4.     Workbooks.Open ("N:\Central Region Reports\Central Region DOL Reports\Archive Central Region DOL Log.xls")
  5.     Sheets("Archive").Select
  6.     ActiveSheet.Unprotect
  7.     Range("B3").Select
  8.     Selection.AutoFilter..
Apr 25 '07 #1
9 2462
atljpe
11
Please let me know if my question is not clear
May 1 '07 #2
Dököll
2,364 Expert 2GB
I'm a beginner:
In MS Excel, my code begins with opening a file located within a shared file & drive. My drive begins with the letter "N" ie. N:\ftwntfilp012 where as other users may give it a different letter such as "Z" ie. Z:\ftwntfilp012.
Is there a way to use this code without having to change the lettering each time someone with a different letter before their drive uses this macro?
I hope I'm clear
Thanks for any assistance
atljpe

Expand|Select|Wrap|Line Numbers
  1. ..Sub NEWSEND()
  2. ActiveWorkbook.Save
  3. 'sub openup()
  4.     Workbooks.Open ("N:\Central Region Reports\Central Region DOL Reports\Archive Central Region DOL Log.xls")
  5.     Sheets("Archive").Select
  6.     ActiveSheet.Unprotect
  7.     Range("B3").Select
  8.     Selection.AutoFilter..
Hello, atljpe!

Nice of you to add a portion of your code...

You can use it as the following:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Workbooks.Open (App.Path &  "\Central Region Reports\Central Region DOL Reports\Archive Central Region DOL Log.xls") 
  3.  
  4.  
Have fun with the project!

Dököll
May 1 '07 #3
atljpe
11
Thanks Dököll for responding............
Appears we're on the right track. I copied the suggested variation into my code but I received a run time 424 error. I tried to follow the help instructions but I was not able to figure out the fix. I also tried minor variations of what you gave me but I was not successful. Was I supposed to add something else to your suggested variation? Do you need more information from me or my code?
Hope you can help....thnx & brgds atljpe
May 2 '07 #4
Denburt
1,356 Expert 1GB
Try adding a breakpoint or even a message to verify that you are arriving at the correct path. If I am not mistaken app.path will lead you to your office program location. Since that is the application that your workbook is open in.

MsgBox app.Path

The following should get you there. This is the Visual Basic forum and is similar in nature however Excell and all office apps use VBA which is Visual basic for Applications. Not to take away from any of the guys in here though just an FYI for future references, the guys here are really talented especially if they are answering questions for both types of code but a VBA forum is probably more suited, such as MS Access. I don't usually move these threads since these guys are so good they more than hold their own.

MsgBox ThisWorkbook.Path

MsgBox activeworkbook.Path
May 2 '07 #5
atljpe
11
Thanks for the education...I didn't know :)
-please show me within the code brackets, exactly how to arrange the MsgBox within the code
-my attempts have been usless
I greatly appreciate your patience

Also, if this string needs to be moved, please do, I'm sure you all have enough to deal with within your own categories than to have outside categories reside within your workloads.
May 2 '07 #6
Denburt
1,356 Expert 1GB
Old line of code:
Expand|Select|Wrap|Line Numbers
  1. Workbooks.Open (App.Path &  "\Central Region Reports\Central Region DOL Reports\Archive Central Region DOL Log.xls") 
New Code:
Expand|Select|Wrap|Line Numbers
  1. 'Check to verify the path is correct.
  2. MsgBox activeworkbook.Path
  3. 'Open the workbook, you may need to make an adjustment to the following statement to correct the path/file
  4. Workbooks.Open (activeworkbook.path &  "\Central Region Reports\Central Region DOL Reports\Archive Central Region DOL Log.xls") 
An alternative is to hard code the servername on down, this is not quite as fast as the previous method but might yield the results you need. A mapped drive is always quicker than using the full servername since a mapped path keeps the connection to that server open. The trick is to get the server name itself then you can easily use the following and it will work for everyone. In most cases you can move the mouse over the mapped drive and after a second or so the tool tip should pop up with the info you need.

Expand|Select|Wrap|Line Numbers
  1. Workbooks.Open ("\\MYSTUPIDSERVERNAME\Central Region Reports\Central Region DOL Reports\Archive Central Region DOL Log.xls") 
May 2 '07 #7
Dököll
2,364 Expert 2GB
Thanks Dököll for responding............
Appears we're on the right track. I copied the suggested variation into my code but I received a run time 424 error. I tried to follow the help instructions but I was not able to figure out the fix. I also tried minor variations of what you gave me but I was not successful. Was I supposed to add something else to your suggested variation? Do you need more information from me or my code?
Hope you can help....thnx & brgds atljpe
Quite welcome, atljpe! Looks like Denburt's idea should work, give that a whil. Please stay tuned if more is needed...
May 3 '07 #8
atljpe
11
Denburt & Dököll,
Thank you very much for your logic power...
The second code worked like a charm, so problem solved...
I will work with the 1st code until I get it right, so I can educate myself more...
Thank You
atljpe
May 3 '07 #9
Denburt
1,356 Expert 1GB
Glad we could help if you have any questions at all please feel free to ask.

BTW

You will find that "Debug.print" is much better than msgbox but I thought it would be best to get your issue fixed first, and i was in a bit of a rush. If you use the following you can see the results in the "immediate" window. You may need to go to the menus click - View - Immediate Window (Ctrl G).


Expand|Select|Wrap|Line Numbers
  1. 'Check to verify the path is correct.
  2. Debug.print activeworkbook.Path
  3.  
  4. Workbooks.Open ("\\MYSTUPIDSERVERNAME\Central Region Reports\Central Region DOL Reports\Archive Central Region DOL Log.xls") 
  5.  
Also (fyi) "Instr" is a very convienient function for parsing or breaking up the paths/folders.
May 3 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Sarah | last post by:
Hello. I am using Microsoft.Office.Interop.Excel in a C# .NET project. I want to open an Excel application with a specific file name. I am currently opening it with this code: ...
4
by: Brad | last post by:
Error when opening a solution with a web services project in it: "Unable to open the Web project 'myproj'. The file path 'c:\code\myservice' does not correspond to the URL...
3
by: Michael | last post by:
Hi everyone :) I have a split database with the backend on a shared folder which users access through the LAN. The front end sits on their hard drives. Apparently windows 2000 has a limit of...
0
by: Dennis | last post by:
I have tried to use the IWshRuntimeLibrary and ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk") to get all Logical Drives, Mapped Network Drives, Shared Folders and Shared Drives with...
11
by: pamelafluente | last post by:
I am doing my own PrintDialog, and have placed there a combo with the printer names, as in the PrintDialog provided by VB.NET. Here is the question: how do I open the native windows printer...
1
by: Ishan Bhalla | last post by:
Hello, Am not sure if i have put this in the wrong discussion group. I have 2 workbooks with 1 worksheet each. I want to merge the workbooks into one. Any idea how to do it? I am using VB.net...
6
by: Mike | last post by:
We are intermitantly receiving this error on our website. ExecuteReader requires an open and available Connection. The connection's current state is connecting. Following is the code from the Load...
2
by: cbs81 | last post by:
hi all, problem: transferring data from workbooks that are stored in a particular directory from excel to a table in access. when done, the workbooks that have been processed are automatically...
22
by: robertgregson | last post by:
Using C#, .NET3.5, Visual Studio 2008 and WCF on Windows VISTA SP1, I have written a service, service host (as a C# console application) and a client. The service uses...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.