Saving to Intranet Site

R

Richard

Hi,

I have automated the saving of an excel workbook to an intranet site, with
the current days date as part of the file name so that the file name looks
some like:
filename yymmdd.
However I would like to automate the creation of new folder names, so that
if there isn't a folder for either the current year, or the current month, or
both, the macro will create them.

I was given the following, but this doesn't appear to work when the folder
address starts with http:

Sub TestDir()

If Dir("C:\Windhoos", vbDirectory) = "" Then
MkDir ("C:\Windhoos")
End If

End Sub


Please advise.

Many Thanks
Richard
 
J

Joel

Excel can't write to network drives which usally start with \\. these drives
need to be mapped to a drive letter. Look at your windows explorer (not
internet explorer) under tools - Map Network drives. You can map a new drive
and then save the file to the drive letter assigned.
 
R

Richard

I am currently writing to this drive which starts http:// The save is
automated as part of a macro, I only want to make this dynamic so that new
folders do not have to be created manually.
 
J

Joel

Check what string the "Save Is" is using to save the file. What ever works
for the save as I would think also should work for the dir. to make your code
dynamic set a variable

myfile = C:\Windhoos",
If Dir(myfile, vbDirectory) = "" Then
MkDir (myfile)
End If
 
T

Tim Williams

Not at work right now, but I'm pretty writing directly to a UNC path is
possible.
No need to map a drive just for that.

If the OP is updating an intranet site then they should get access to the
filesystem and not use http for creating files.

Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top