Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default New Folder, Workbook, and Worksheet

I'm trying to figure out a way to create a routine that when activated
will

1) Place a new folder on the desktop

When another situation is true

2) Create a new workbook with a name that is in a string

When another situation is true

3) Add a new worksheet in the workbook with a name that is held in a
string

My biggest struggle is the last item. The only routine I've found to
rename a worksheet requires that I know the name of the active
worksheet. But everytime I add a new worksheet it gets indexed with a
new name (e.g. Sheet1, Sheet2, Sheet3, etc.). Do I have to track this
or is there an easier way.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default New Folder, Workbook, and Worksheet

Hi

1 + 2

Add folder and add/save a workbook in that folder

Sub test()
Dim wsh As Object
Dim fs As Object
Dim DesktopPath As String
Dim DirString As String
Dim fname As String
Dim wb As Workbook

Set wsh = CreateObject("WScript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")
DesktopPath = wsh.SpecialFolders.Item("Desktop")
DirString = DesktopPath & "\Testfolder"

If Not fs.FolderExists(DirString) Then
fs.CreateFolder DirString
Else
End If

Application.ScreenUpdating = False
fname = DirString & "\Ron.xls"
Workbooks.Add xlWBATWorksheet
Set wb = ActiveWorkbook
With wb
.SaveAs fname
.Close False
End With
Application.ScreenUpdating = True
End Sub



3)
Worksheets.Add.Name = "Ron"


--
Regards Ron de Bruin
http://www.rondebruin.nl


" wrote in message ...
I'm trying to figure out a way to create a routine that when activated
will

1) Place a new folder on the desktop

When another situation is true

2) Create a new workbook with a name that is in a string

When another situation is true

3) Add a new worksheet in the workbook with a name that is held in a
string

My biggest struggle is the last item. The only routine I've found to
rename a worksheet requires that I know the name of the active
worksheet. But everytime I add a new worksheet it gets indexed with a
new name (e.g. Sheet1, Sheet2, Sheet3, etc.). Do I have to track this
or is there an easier way.



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
Macro to update active workbook in one folder Mike @ GD Excel Worksheet Functions 8 January 15th 09 02:19 PM
Workbook saved in FTP folder AP[_3_] Excel Discussion (Misc queries) 2 January 5th 09 12:53 PM
Move Active Workbook to another Folder jonallen51 Excel Discussion (Misc queries) 0 March 12th 08 07:41 PM
Link with workbook in other folder which is in another group Frank Situmorang Excel Discussion (Misc queries) 3 April 5th 07 05:50 AM
Force a Readonly Workbook to save to a different folder Charlotte Howard Excel Discussion (Misc queries) 6 August 23rd 06 04:41 PM


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