Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by Seamus2626
at 2024-07-17 02:35:11
Point:500 Replies:6 POST_ID:829003USER_ID:11690
Topic:
Microsoft Excel Spreadsheet Software;;
Hi,
A different user has a slightly different path to a spreadsheet as another
User 1
"x:Morris InfoME_Morris_ProjectME Downloads"
User 2
"x:SPMMorris InfoME_Morris_ProjectME Downloads"
So i am using "Workbooks.Open Filename:= _"
Is there a line of code to say, if path "x:Morris InfoME_Morris_ProjectME Downloads" not found, then try path
"x:SPMMorris InfoME_Morris_ProjectME Downloads"
Many thanks
A different user has a slightly different path to a spreadsheet as another
User 1
"x:Morris InfoME_Morris_ProjectME Downloads"
User 2
"x:SPMMorris InfoME_Morris_ProjectME Downloads"
So i am using "Workbooks.Open Filename:= _"
Is there a line of code to say, if path "x:Morris InfoME_Morris_ProjectME Downloads" not found, then try path
"x:SPMMorris InfoME_Morris_ProjectME Downloads"
Many thanks
Expert: duncanb7 replied at 2024-07-17 06:24:44
Thanks for your points
Have a nice day
Duncan
Have a nice day
Duncan
Author: Seamus2626 replied at 2024-07-17 06:23:05
Thanks Duncan!
Accepted Solution
Expert: duncanb7 replied at 2024-07-17 03:30:32
500 points EXCELLENT
Ignore in last previous post, try this with directory check from vbDirectory at
http://www.techonthenet.com/excel/formulas/dir.php
http://www.techonthenet.com/excel/formulas/dir.php
sub test()Filename="example.xls"localfile="x:Morris InfoME_Morris_ProjectME Downloads"localfile2="x:SPMME_Morris_ProjectME Downloads"If Dir(localfile ,vbDirectory) <> "" Then MsgBox "File exists."'Do your code here Workbooks.Open Filename:=localfile & "" & FilenameElse MsgBox "File doesn't exist."'Do you cod hereWorkbooks.Open Filename:= localfile2 & "" & FilenameEnd IfEnd Sub 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:
Expert: duncanb7 replied at 2024-07-17 03:27:19
Try this
Duncan
Duncan
sub test()Filename="example.xls"localfile="x:Morris InfoME_Morris_ProjectME Downloads"localfile2="x:SPMME_Morris_ProjectME Downloads"If Dir(localfile & "" & Filename) <> "" Then MsgBox "File exists."'Do your code here Workbooks.Open Filename:=localfile & "" & FilenameElse MsgBox "File doesn't exist."'Do you cod hereWorkbooks.Open Filename:= localfile2 & "" & FilenameEnd IfEnd Sub 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:
Author: Seamus2626 replied at 2024-07-17 03:21:35
Thanks Duncan,
When running the code, its is skipping to
Else
Workbooks.Open Filename:=localfile2 & "" & Filename
Whereas localfile is available, and should be opening, it is skipping to localfile2 which is not available from my PC!
Thanks
When running the code, its is skipping to
Else
Workbooks.Open Filename:=localfile2 & "" & Filename
Whereas localfile is available, and should be opening, it is skipping to localfile2 which is not available from my PC!
Thanks
Expert: duncanb7 replied at 2024-07-17 02:56:01
You need Dir() function on VBA to check the file path existing or not
before switching to other file path
Duncan
before switching to other file path
Duncan
sub test()Filename="example.xls"localfile="x:Morris InfoME_Morris_ProjectME Downloads"localfile2="x:SPMME_Morris_ProjectME Downloads"If Dir(localfile) <> "" Then MsgBox "File exists."'Do your code here Workbooks.Open Filename:=localfile & "" & FilenameElse MsgBox "File doesn't exist."'Do you cod hereWorkbooks.Open Filename:= localfile2 & "" & FilenameEnd IfEnd Sub 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16: