Conquering SaveAs in VBA - Saving in Multiple File Formats - CODE and Download Included

preview_player
Показать описание
Conquering SaveAs in VBA - File Formats
**Get the Excel file here
**Grab the Free VBA Quick Reference Guide

This video explores best practices and hopes to shed light on some issues you will run into when using the SaveAs Method in VBA.

Digging deeper into "SaveAs" will uncover some annoying workarounds when saving a file in a different file format.

In the first section of the code, we use the "Thisworkbook.FullName" property to get the file path as a string. This string is the location where we will save the file. Next, we turn off alerts using "Application.DisplayAlerts = False". By adding this line of code, we allow Excel to Save our file over the existing file with no problem and no warnings. To complete the basic save as we use Activeworkbook.SaveAs and add the file path we got from the "FullName" property. The easy work is complete.

At this point, we could have easily saved all the files and file types by adding the correct extensions and file formats, and we would have been successful with terribly named files. To avoid this, we use a file scripting object to identify the extension and remove it from the string we are using as the file path destination. We add the correct extension to the string and add the correct file type, and the files save as we expect, like magic. Now pat yourself on the back because you have conquered the challenge of Fileformats when using SaveAs in Excel VBA. You can save a file as the following extensions (xls,xlsx,xlsb,xlsm, and csv)
Рекомендации по теме
Комментарии
Автор

your videos saved me on my midterm thank you

evanimtiaz
Автор

Surprised you dont have more subscribers! Great content

XShollaj
Автор

Thanks man for posting video that what i am looking for..savs as with file type..typically xlsm

datascientistoflife
Автор

Question:
I make multiple CSV with VBA and the code works perfectly with one issue.
My CSV should be in semicolon and comma as a decimal delimiter but! CSV created by VBA is always comma as column separator and dot as decimal separator.
Does anybody know how you can change that in VBA?

danushairan