LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Create a macro-enabled workbook through VB

Hi Oz8425

Try this

Sub Test()
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim WB As Workbook
Dim TempFilePath As String
Dim TempFileName As String

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

Set WB = Workbooks.Add
FileExtStr = ".xlsm": FileFormatNum = 52

'Save the new workbook and close it
TempFilePath = Application.DefaultFilePath & "\"
TempFileName = "NewWB " & Format(Now, "dd-mmm-yy h-mm-ss")

With WB
.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
.Close SaveChanges:=False
End With

MsgBox "You can find the new file in " & Application.DefaultFilePath

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub


See also
http://www.rondebruin.nl/saveas.htm




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Oz8425" wrote in message ...
I'm looking to create a new macro-enabled workbook (extension .xlsm) by using
a macro in a different workbook. I only know how to create a workbook with
extension .xls and when I attempt to create a .xlsm I get an error.

Any help would be appreciated.

 
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
Excel Macro-enabled Workbook Salza Excel Discussion (Misc queries) 2 May 16th 10 03:57 AM
need help to update macro to office 2007 macro enabled workbook jatman Excel Discussion (Misc queries) 1 December 14th 07 01:57 PM
Default a workbook to save as a xlsm (macro-enabled) in 2007 Razzer204 Excel Discussion (Misc queries) 3 March 21st 07 06:10 PM
how to track changes in a workbook with macros enabled Jerjuice Excel Discussion (Misc queries) 0 October 11th 06 06:16 PM
how to track changes in a workbook with macros enabled Jerjuice Excel Discussion (Misc queries) 0 October 11th 06 06:15 PM


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