Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Using Macros to write Links

I am attempting to write a macro that will link to a file on a server.
Several portions of the path are variables so that the user can input
specific dates.

The path is quite long:

\\USPSPS01\E-MOMO\...\Line 1\...\[L1 21 2009.xls]1ST SHIFT'!$I$20

If I screwed up the syntax, its because I'm working from memory...

Here's the problem...each time the macro runs, I get a file explorer window
and I have to point to the file. The problem is, I have some 216 links that I
want to write!

If input the formula in the form ='\\USPS.... then I get the data without
pointing, but use the macro to write the formula and I have to point to
it...is there no way to do this in Excel. I know there's a way in Access, but
I am not familiar with Access!

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Using Macros to write Links

I'm not sure I understand, but I bet that the dialog that you're seeing is excel
saying that the formula you just entered refered to a location (either workbook
or worksheet) that didn't exist where you said it did.

The only solution I know is to be more careful--you could even test to see if
the file existed before you plop the formula into a cell.

dim TestStr as string
dim myPath as string
dim myFileName as string

mypath = "\\that long path\" 'with the trailing backslash
myfilename = "l1 21 2009.xls"

teststr = ""
on error resume next
teststr = dir(mypath & myfilename)
on error goto 0

if teststr = "" then
'no file with that name exists at that location
'what should happen
else
'the file exists
'plop the formula into the cell
end if

You could even open the file to see if there was a worksheet inside that
workbook with that name. Then do the plopping of the formula into the cell.



TomK76 wrote:

I am attempting to write a macro that will link to a file on a server.
Several portions of the path are variables so that the user can input
specific dates.

The path is quite long:

\\USPSPS01\E-MOMO\...\Line 1\...\[L1 21 2009.xls]1ST SHIFT'!$I$20

If I screwed up the syntax, its because I'm working from memory...

Here's the problem...each time the macro runs, I get a file explorer window
and I have to point to the file. The problem is, I have some 216 links that I
want to write!

If input the formula in the form ='\\USPS.... then I get the data without
pointing, but use the macro to write the formula and I have to point to
it...is there no way to do this in Excel. I know there's a way in Access, but
I am not familiar with Access!

Thanks!


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Using Macros to write Links

Dave,

Thanks for the reply.

The long path is good, I know becuase I can manually type the formula into
the cell and it works. So I try with a macro. Problem is that the files are
on a server, so using a path that starts with "E:\" won't work because the
server is not mapped as E: on everyon's drive, so I used the \\USPSPS01\.

So I am not sure whats going on...

"TomK76" wrote:

I am attempting to write a macro that will link to a file on a server.
Several portions of the path are variables so that the user can input
specific dates.

The path is quite long:

\\USPSPS01\E-MOMO\...\Line 1\...\[L1 21 2009.xls]1ST SHIFT'!$I$20

If I screwed up the syntax, its because I'm working from memory...

Here's the problem...each time the macro runs, I get a file explorer window
and I have to point to the file. The problem is, I have some 216 links that I
want to write!

If input the formula in the form ='\\USPS.... then I get the data without
pointing, but use the macro to write the formula and I have to point to
it...is there no way to do this in Excel. I know there's a way in Access, but
I am not familiar with Access!

Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Using Macros to write Links

How long is the string that points at that UNC path? (Maybe there's a length
limit that's being broken????)

But my guess is that your path is still wrong.

I'd try this:

Dim myPath as string
dim testStr as string
myPath = "\\...." 'that long path
if right(mypath,1) < "\" then
mypath = mypath & "\" 'make sure there's a trailing backslash
end if

teststr = ""
on error resume next
teststr = dir mypath & "nul"
on error goto 0

if teststr = "" then
msgbox "That path wasn't found!"
else
msgbox "it's ok"
end if



TomK76 wrote:

Dave,

Thanks for the reply.

The long path is good, I know becuase I can manually type the formula into
the cell and it works. So I try with a macro. Problem is that the files are
on a server, so using a path that starts with "E:\" won't work because the
server is not mapped as E: on everyon's drive, so I used the \\USPSPS01\.

So I am not sure whats going on...

"TomK76" wrote:

I am attempting to write a macro that will link to a file on a server.
Several portions of the path are variables so that the user can input
specific dates.

The path is quite long:

\\USPSPS01\E-MOMO\...\Line 1\...\[L1 21 2009.xls]1ST SHIFT'!$I$20

If I screwed up the syntax, its because I'm working from memory...

Here's the problem...each time the macro runs, I get a file explorer window
and I have to point to the file. The problem is, I have some 216 links that I
want to write!

If input the formula in the form ='\\USPS.... then I get the data without
pointing, but use the macro to write the formula and I have to point to
it...is there no way to do this in Excel. I know there's a way in Access, but
I am not familiar with Access!

Thanks!


--

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
Help to write the macros given a set of data sengtng1 Excel Programming 2 February 19th 09 02:09 PM
How to write macros Aries6 Excel Discussion (Misc queries) 2 December 16th 05 03:40 PM
macro to write other macros? Darren Hill[_3_] Excel Programming 1 May 19th 05 07:10 PM
Can you freely write excel macros in C# yet? Sayeed Excel Programming 0 March 28th 05 05:56 AM
write error - even when no macros run Jabba Excel Programming 0 October 26th 04 12:53 PM


All times are GMT +1. The time now is 01:02 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"