Programatically create Personal Macro Workbook using VBA

pingme89

Board Regular
Joined
Jan 23, 2014
Messages
176
Office Version
  1. 365
Platform
  1. Windows
I want to create a Personal Macro Workbook programmatically with VBA. I am having an issue creating it.
This is what I currently have:
VBA Code:
personalWBName = "PERSONAL.XLSB"
personalFilePath = Application.UserLibraryPath & personalWBName

Application.Workbooks.Add
Set personalWB = ActiveWorkbook
personalWB.SaveAs FileName:=personalFilePath, FileFormat:=xlOpenXMLWorkbookMacroEnabled

On the last line of code, I get a runtime error 1004. This extension cannot be used with the selected file type.

How else can I approach this problem? Any help would be greatly appreciated.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Try replacing....

VBA Code:
Application.UserLibraryPath

with

VBA Code:
Application.StartupPath

Hope this helps!
 
Upvote 0
Try replacing....

VBA Code:
Application.UserLibraryPath

with

VBA Code:
Application.StartupPath

Hope this helps!
I am still getting the same Runtime error 1004. with the modification
 
Upvote 0
Oh right, missed it, should replace...

VBA Code:
FileFormat:=xlOpenXMLWorkbookMacroEnabled

with

VBA Code:
FileFormat:=xlExcel12 'excel binary workbook

Hope this helps!
 
Upvote 1
Solution
Oh right, missed it, should replace...

VBA Code:
FileFormat:=xlOpenXMLWorkbookMacroEnabled

with

VBA Code:
FileFormat:=xlExcel12 'excel binary workbook

Hope this helps!
That solved the problem. Much thanks.
 
Upvote 0

Forum statistics

Threads
1,223,880
Messages
6,175,154
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top