Fire up a backup with VBA code in Excel

You can ask general questions, share opinions or advices about FBackup
JeffL
Posts: 10
Joined: Sun Apr 07, 2013 12:47 am

Fire up a backup with VBA code in Excel

Postby JeffL » Wed May 22, 2019 9:04 pm

I have an FBackup job running every two hours to backup changes to an Excel file to my Goggle Drive that I may change a few times during the day. It occurred to me that it would be more efficient to automatically backup the file when I save the Excel file. I'm sure there's a way to do this but I'm hoping someone can save me from completely reinventing the wheel. I'm assuming it would involve some VBA code in Excel to run an FBackup job in the Task Scheduler. Any thoughts (or code)? :geek:

Never mind. After some research I can see this is going to be simple. Just create a shortcut to the job and run it from VBA. :oops:

JeffL
Posts: 10
Joined: Sun Apr 07, 2013 12:47 am

Re: Fire up a backup with VBA code in Excel

Postby JeffL » Thu May 23, 2019 2:12 am

If anyone is interested, here is the VBA code to run the backup (pretty easy):

Dim Backup
Dim BakcupPath

BackupPath = "C:\Program Files (x86)\Softland\FBackup 8\bSchedStarter.exe" _
& " /HIDE /R" _
& " {4A824D26-0A22-41D0-AD81-74A36FBDE6FE}" _
& " -PRIORITY 2)"

Backup = Shell(BackupPath, 1)


The path was copied from the properties of the shortcut, and broken up for clarity in the code.
/HIDE prevents the FBackup screen from appearing during the backup.
Last edited by JeffL on Fri May 24, 2019 5:04 am, edited 1 time in total.

JeffL
Posts: 10
Joined: Sun Apr 07, 2013 12:47 am

Re: Fire up a backup with VBA code in Excel

Postby JeffL » Thu May 23, 2019 6:58 pm

Another way -

This backup is triggered from an Excel file. When away from home, I send the most recent Excel file to my notebook. Each computer has FBackup installed, and it didn't take me long to realize that having the path in the Excel VBA file wasn't going to work because each computer has it's own job number for the backup job.

My first thought was to have the VBA run the shortcut .LNK file, since each computer would have it's own .LNK file with the correct job address for the computer being used. I then found that the SHELL command doesn't work with .LNK files, you need ShellExecute which requires a lot of code lines and was more complicated than I willing to deal with at the moment.

My solution (which works and is simple) was to change the SHELL command to run a .bat file:

Dim Backup
Backup = Shell("C:\Jeff\SS\PortFBackup.bat", 1)


The .bat file is simply the path from the backup shortcut:

"C:\Program Files (x86)\Softland\FBackup 8\bSchedStarter.exe" /HIDE /R "{4A824D26-0A22-41D0-AD81-74A36FBDE6FE}" -PRIORITY 2

With the .bat file on both computers, each with it's own unique job number in the brackets, the backup job is found on both computers.


Return to “General”