PC Review


Reply
Thread Tools Rate Thread

Create a macro-enabled workbook through VB

 
 
=?Utf-8?B?T3o4NDI1?=
Guest
Posts: n/a
 
      18th Mar 2007
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.
 
Reply With Quote
 
 
 
 
Ron de Bruin
Guest
Posts: n/a
 
      18th Mar 2007
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" <(E-Mail Removed)> wrote in message news90B84FA-0539-4031-9652-(E-Mail Removed)...
> 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.

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Macro-enabled Workbook Salza Microsoft Excel Misc 2 16th May 2010 03:57 AM
Creating macro enabled Excel 2007 workbook Ken Warthen Microsoft Excel Programming 2 19th Sep 2009 06:32 PM
need help to update macro to office 2007 macro enabled workbook jatman Microsoft Excel Misc 1 14th Dec 2007 01:57 PM
can't find macros in a macro-enabled workbook Dave F Microsoft Excel Programming 6 20th Aug 2007 04:48 PM
Default a workbook to save as a xlsm (macro-enabled) in 2007 =?Utf-8?B?UmF6emVyMjA0?= Microsoft Excel Misc 3 21st Mar 2007 06:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:29 AM.