Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default saving to two places by selecting one (VBA)


Hi, I have this code that lists some things and then it saves it in a
user selected folder, and I want to save to the selected folder and the
folder above it. Also, I want after it lists the things it lists then it
rights the name of the "selected" folder you save it in, but not the
folder above it.


Sub fill_file_names()
Dim user_pick As String
Dim r As Integer

Application.DisplayAlerts = False
Workbooks.Add
Range("1:1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Range("1:1").Select
user_pick = PickFolder("C:\") + "\*detail*.wk4"
r = 1
next_file = Dir(user_pick)

Do Until next_file = ""
Sheets("Sheet1").Select
Sheets("sheet1").Cells(r, 1) = next_file
next_file = Dir()
r = r + 1
Loop

ActiveWorkbook.SaveAs Filename:="tran.wk4", FileFormat:=xlWK4, _
CreateBackup:=False
ActiveWorkbook.Save
ActiveWorkbook.Close

Application.DisplayAlerts = True
End Sub

Function PickFolder(strStartDir As Variant) As String
Application.DisplayAlerts = False
Dim SA As Object, f As Object
Set SA = CreateObject("Shell.Application")
Set f = SA.BrowseForFolder(0, "Choose a folder", 0, strStartDir)
If (Not f Is Nothing) Then
PickFolder = f.Items.Item.Path
End If
Set f = Nothing
Set SA = Nothing
End Function


--
tim64
------------------------------------------------------------------------
tim64's Profile: http://www.excelforum.com/member.php...o&userid=23295
View this thread: http://www.excelforum.com/showthread...hreadid=380118

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default saving to two places by selecting one (VBA)


what do you mean by save to the selected folder and the folder abov
it, what is folder above it mean?, There might be many folders abov
the selected folder, which folder is the exact folder that the fil
need to be saved

--
anilsolipura
-----------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...fo&userid=1627
View this thread: http://www.excelforum.com/showthread.php?threadid=38011

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default saving to two places by selecting one (VBA)


like the folders root folder. (example) C:\programs\something
.................................................. ..............^...................^
.................................................. ..............^...................^
.................................................. ....folder abov
it.........^
.................................................. ..........................folde
selected


the periods are to keep them in plac

--
tim6
-----------------------------------------------------------------------
tim64's Profile: http://www.excelforum.com/member.php...fo&userid=2329
View this thread: http://www.excelforum.com/showthread.php?threadid=38011

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default saving to two places by selecting one (VBA)


This code would save in selected folder, but I am not clear about the
folder above it

Sub fill_file_names()
Dim user_pick As String
Dim r As Integer

Application.DisplayAlerts = False
Workbooks.Add
Range("1:1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Range("1:1").Select
user_pick = PickFolder("C:\")
r = 1
NEXT_FILE = Dir(user_pick + "\*p*.wk4")
Do Until NEXT_FILE = ""
Sheets("Sheet1").Select
Sheets("Sheet1").Cells(r, 1) = NEXT_FILE
NEXT_FILE = Dir()
r = r + 1
Loop
ActiveWorkbook.SaveAs Filename:=user_pick & "tran.wk4",
FileFormat:=xlWK4, _
CreateBackup:=False
ActiveWorkbook.Save
ActiveWorkbook.Close

Application.DisplayAlerts = True
End Sub

Function PickFolder(strStartDir As Variant) As String
Application.DisplayAlerts = False
Dim SA As Object, f As Object
Set SA = CreateObject("Shell.Application")
Set f = SA.BrowseForFolder(0, "Choose a folder", 0, strStartDir)
If (Not f Is Nothing) Then
PickFolder = f.Items.Item.Path
End If
Set f = Nothing
Set SA = Nothing
End Function


--
anilsolipuram
------------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...o&userid=16271
View this thread: http://www.excelforum.com/showthread...hreadid=380118

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default saving to two places by selecting one (VBA)


When I say "folder above it" I mean its root folder.

So I guess what I want is for the program to save tran.wk4 in th
selected folder and that folders root folder. for example, selecte
folder -- "project_test0001" and root folder -- "project_test". Als
for the second part I want the name of the selected folder to be at th
end of the list this code makes

--
tim6
-----------------------------------------------------------------------
tim64's Profile: http://www.excelforum.com/member.php...fo&userid=2329
View this thread: http://www.excelforum.com/showthread.php?threadid=38011



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default saving to two places by selecting one (VBA)


try this macro

Sub macro()
Cells(2, 3).Select
End Sub
Sub fill_file_names()
Dim user_pick As String
Dim r As Integer

Application.DisplayAlerts = False
Workbooks.Add
Range("1:1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Range("1:1").Select
user_pick = PickFolder("C:\")
MsgBox user_pick
r = 1
NEXT_FILE = Dir(user_pick + "\*detail*.wk4")
Do Until NEXT_FILE = ""
Sheets("Sheet1").Select
Sheets("Sheet1").Cells(r, 1) = NEXT_FILE
NEXT_FILE = Dir()
r = r + 1
Loop
ActiveWorkbook.SaveAs Filename:=user_pick & "tran.wk4",
FileFormat:=xlWK4, _
CreateBackup:=False
temp = Split(user_pick, "\")
temp1 = temp(UBound(temp))
temp2 = Split(user_pick, temp1)
ActiveWorkbook.SaveAs Filename:=temp2(0) & "tran.wk4",
FileFormat:=xlWK4, _
CreateBackup:=False
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub

Function PickFolder(strStartDir As Variant) As String
Application.DisplayAlerts = False
Dim SA As Object, f As Object
Set SA = CreateObject("Shell.Application")
Set f = SA.BrowseForFolder(0, "Choose a folder", 0, strStartDir)
If (Not f Is Nothing) Then
PickFolder = f.Items.Item.Path
End If
Set f = Nothing
Set SA = Nothing
End Function


--
anilsolipuram
------------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...o&userid=16271
View this thread: http://www.excelforum.com/showthread...hreadid=380118

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default saving to two places by selecting one (VBA)


No, I don't want the name of the folder you choose to be part o
tran.wk4's name. I want the name of the folder you choose to be at th
end of the list IN tran.wk4, but otherwise everything else is good

--
tim6
-----------------------------------------------------------------------
tim64's Profile: http://www.excelforum.com/member.php...fo&userid=2329
View this thread: http://www.excelforum.com/showthread.php?threadid=38011

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default saving to two places by selecting one (VBA)


I am not clear about this, can you explain with example

--
anilsolipura
-----------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...fo&userid=1627
View this thread: http://www.excelforum.com/showthread.php?threadid=38011

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default saving to two places by selecting one (VBA)


(example)ok say I have a folder named Project_test, and in that folder
have a sub-folder named project_test0007. In project_test0007 there'
five files "detail1.wk4", "detail2.wk4", "detail3.wk4", "detail4.wk4"
and "detail5.wk4". So when I run the program I choose the sub-folde
project_test0007 then the program lists the names of the files i
project_test0007 from A1 to A5, and then after it lists the file name
it lists the sub-folder name "project_test0007" in A6. Then it save
the file, tran.wk4, in the folder Project_test

--
tim6
-----------------------------------------------------------------------
tim64's Profile: http://www.excelforum.com/member.php...fo&userid=2329
View this thread: http://www.excelforum.com/showthread.php?threadid=38011

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default saving to two places by selecting one (VBA)


Try this macro and let me know

Sub fill_file_names()
Dim user_pick As String
Dim r As Integer

Application.DisplayAlerts = False
Workbooks.Add
Range("1:1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Range("1:1").Select
user_pick = PickFolder("C:\")

r = 1
NEXT_FILE = Dir(user_pick + "\*detail*.wk4")
Do Until NEXT_FILE = ""
Sheets("Sheet1").Select
Sheets("Sheet1").Cells(r, 1) = NEXT_FILE
NEXT_FILE = Dir()
r = r + 1
Loop
Sheets("Sheet1").Cells(r, 1) = user_pick
temp = Split(user_pick, "\")
temp1 = temp(UBound(temp))
temp2 = Split(user_pick, temp1)
MsgBox temp2(0)
ActiveWorkbook.SaveAs Filename:=temp2(0) & "tran.wk4",
FileFormat:=xlWK4, _
CreateBackup:=False
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub

Function PickFolder(strStartDir As Variant) As String
Application.DisplayAlerts = False
Dim SA As Object, f As Object
Set SA = CreateObject("Shell.Application")
Set f = SA.BrowseForFolder(0, "Choose a folder", 0, strStartDir)
If (Not f Is Nothing) Then
PickFolder = f.Items.Item.Path
End If
Set f = Nothing
Set SA = Nothing
End Function


--
anilsolipuram
------------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...o&userid=16271
View this thread: http://www.excelforum.com/showthread...hreadid=380118



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default saving to two places by selecting one (VBA)


It works PERFECTLY, thank you for everything!

--
tim6
-----------------------------------------------------------------------
tim64's Profile: http://www.excelforum.com/member.php...fo&userid=2329
View this thread: http://www.excelforum.com/showthread.php?threadid=38011

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
My places Bar Rviv Excel Discussion (Misc queries) 8 January 20th 10 11:12 PM
Automaticly saving formula's to values when saving Gunti Excel Discussion (Misc queries) 8 November 11th 08 09:34 AM
Saving a workbook in two places. Luke Slotwinski Excel Discussion (Misc queries) 7 May 25th 07 08:45 PM
Saving a Workbook: Forcing User to Rename before Saving Rollin_Again[_6_] Excel Programming 5 April 16th 04 02:54 PM
Saving Documents from templates to specific places Linds[_2_] Excel Programming 1 October 23rd 03 04:25 PM


All times are GMT +1. The time now is 06:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"