VBA Snippets: Execute URL or Application

MicrosoftThis post is part of the series on VBA Snippets.

it is possible to execute a URL or application in VBA using the Windows Shell Execute API function. In this snippet I am executing a URL, but this could be an application.

Before you can call ShellExecute in code you need to add the following line to the declarations at the top of the mdoule:

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

The following VBA command will execute the supplied URL (or application); the highlighted variable contains the URL:

iResult = ShellExecute(0, "open", sReportURL, vbNullString, vbNullString, vbNormalFocus)

You can then use the iResult for error handling.

VBA Snippets: Sleep

MicrosoftThis post is part of the series on VBA Snippets.

The following VBA snippets can be used to set a pause (sleep) in the code.

The first one needs to be in the declarations at the top of the module:

Private Declare Sub Sleep Lib "kernel32" (ByVal milliseconds As Long)

The second is used where you want the code to pause (my recent use was to pause for five seconds after an error and before retrying the action):

Sleep (1000 * 5)

The highlighted section is the time; 1000 milliseconds multiplied by 5 to give me 5 seconds.

VBA Snippets: Series Index

MicrosoftWe’ve recently taken on a new client for support of Microsoft Dynamics GP who has a number of modified forms and reports which have been extended with VBA code to add additional functionality. I have done a reasonable amount of VBA and VB6 in the past, but that was sometime ago and I’ve found myself searching online for examples on how to do some things when they’ve asked for further modifications, so I’ve decided that I’ll post snippets of VBA code here so I can easily find how to do things.

I’ve already been doing similar posts with Network Shell Snippets and PowerShell Snippets. The series index will automatically update as posts go live, but if you’re reading a syndicated version, you’ll need to check back to the original post

VBA Snippets
Sleep
Execute URL or Application
Adding an SQL ODBC Connection in Microsoft Dynamics GP
Select Records from Microsoft Dynamics ODBC Connection
Open a File for Appending

Excluding Folders From a Cron Backup

Cron JobsA while ago, I posted an article on using cron to make backups of folders on Linux web hosting. One issue I’ve become aware of since then is that there are some folders I want to exclude from the backup process. I did some exploring and found the --exclude switch can be used to exclude a single folder; to exclude multiple folders, you can use the switch multiple times.

The example below, excludes the backup folder and anything which has a name starting with a .:

/*
Created by Ian Grieve of azurecurve | Ramblings of an IT Professional (http://www.azurecurve.co.uk) This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0 Int). */
/bin/tar -czvf /home/{username]/backups/backup_{foldername}_$(date +\%Y\%m\%d\%H\%M\%S).tar.gz --exclude=backups --exclude=".*" /home/{username}/{foldername}

The highlighted section shows the two exclude switches used to exclude the folders and files we don’t want to backup.

azurecurve ClassicPress Plugins: Events

ClassicPress PluginsThis is part of the azurecurve ClassicPress Plugins which introduces the plugins I have available for ClassicPress.

The plugin I am going to cover in this post, is a brand new one written for ClassicPress; Events.

Functionality

Events allows events such as webinars or conferences to be created via a custom post type; categories, excerpt, details, start and end dates and times and a featured image are all supported.

In the options set defaults for the widget and shortcode.

Multiple widgets can be created, each assigned to display a category; settings for title, image size and limit for number of events to list can be set per widget.

The event shortcode accepts three parameters:
* slug to select specific event.
* width to set the size of the featured image.
* height to set the size of the featured image.

Shortcode usage is [event slug=”december-2021″ width=150 height=150]; all parameters are optional and will use the defaults set via the settings page.

The events shortcode accepts four parameters:
* category to restrict the output to the selected category.
* width to set the size of the featured image.
* height to set the size of the featured image.
* limit to restrict the number of events to display.

Shortcode usage is [events category=”webinars” width=150 height=150 limit=5]; all parameters are optional and will use the defaults set via the settings page.

Download

The plugin can be downloaded via my Development site.

Click to show/hide the azurecurve ClassicPress Plugins Series Index

GitHub make licensing changes with all core features now free for everyone

GitHubGit hub have recently announced changes to their licensing, so that everyone now has free access to all core features. This includes unlimited collaborators in private repositories.

The key changes are:

  • GitHub Free for organizations is immediately available and includes private repositories for unlimited users
  • All organizations previously using Team for Open Source now have GitHub Free
  • GitHub Free for individual developers now includes unlimited collaborators
  • Organizations and individuals using GitHub Free will receive GitHub Community Support
  • GitHub Pro will now include 2GB of Packages storage and 10GB of data transfer
  • GitHub Pro now has reduced the monthly price from $7 to $4
  • GitHub Team now has reduced the monthly price $7 to $4 per user with no minimum seat requirement
  • GitHub Team will include 3,000 Actions minutes per month for private repositories after May 14

All details on the changes are available from the FAQ about changes to GitHub’s plans.

ClassicPress Development with GitHub: Creating release zips

GitHubWhen I started developing plugins for ClassicPress I decided that I needed to be using source control. As ClassicPress is intending to use GitHub for their plugin directory, it made sense for me to use it as well. This post is part of a series on ClassicPress Development with GitHub.

In the last post of this series, when discussing creating a release, I mentioned that you should upload a zip file containing the release code.

While users can download the source code directly, this will leave -master on the folder name. By creating a release zip, you can avoid this.

I have developed quite a few plugins for ClassicPress and have instances where I make changes to several plugins for release at the same time. To make this easier, I have a Windows batch command which will call 7-zip to compress all folders, in the same folder as the batch file, as zip files:

for /d %%X in (*) do "c:\Program Files\7-Zip\7z.exe" a -xr!.git\ -xr!*~ "%%X.zip" "%%X\"

I didn’t create this command line statement all on my own, but think I might have added the argument to exclude files with a .git suffix. Unfortunately, I started using it a few months ago and do not remember from where the original script came.

ClassicPress Development with GitHub: Create Release

GitHubWhen I started developing plugins for ClassicPress I decided that I needed to be using source control. As ClassicPress is intending to use GitHub for their plugin directory, it made sense for me to use it as well. This post is part of a series on ClassicPress Development with GitHub.

When developing with GitHub, you can make a release; this is a way of grouping together all of the changes since the last release to make it easy to download that particular code set. One point to note, is that while GitHub will automatically create a zip of the source code, this isn’t suitable to use for a ClassicPress release as it will include -master in the contained directory name. However, you can upload a zip file containing the code in the correct folder.

To create a new release, load the repository page on GitHub and click the releases button (red ringed):

Repository page

Continue reading “ClassicPress Development with GitHub: Create Release”

ClassicPress Development with TortoiseGit: Revert Last Commit

TortoiseGitWhen I started developing plugins for ClassicPress I decided that I needed to be using source control. As ClassicPress is intending to use GitHub for their plugin directory, it made sense for me to use it as well. This post is part of a series on ClassicPress Development with TortoiseGit which is a sub-series of the ClassicPress Development with GitHub series.

When you have changes committed to GitHub, you need to make a release of your plugin. Making a release has two main benefits:

  1. It labels the files in the repository with a tag making it easy to download a particular version of the plugin.
  2. You can upload a zip file containing the plugin folder giving a zip file which users can download and upload to their ClassicPress site.

To create a release, open the GitHub repository page and click the releases link at the top (ringed in red):

Github repository

Continue reading “ClassicPress Development with TortoiseGit: Revert Last Commit”

ClassicPress Development with TortoiseGit: Commit

TortoiseGitWhen I started developing plugins for ClassicPress I decided that I needed to be using source control. As ClassicPress is intending to use GitHub for their plugin directory, it made sense for me to use it as well. This post is part of a series on ClassicPress Development with TortoiseGit which is a sub-series of the ClassicPress Development with GitHub series.

Once the repository has been cloned and changes made, you need to submit the changes back to the repository to keep control of changes. This is referred to as a “commit”. To commit your change, right-click the folder (or file) to commit and select Git Commit -> “master” on the context menu:

Git Commit

Continue reading “ClassicPress Development with TortoiseGit: Commit”