├── LICENSE ├── README.md ├── images └── logo.png ├── package.json ├── renovate.json └── snippets └── vba-snippets.json /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 spences10 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VBA Snippets 2 | 3 | [![Greenkeeper badge](https://badges.greenkeeper.io/spences10/vba-snippets.svg)](https://greenkeeper.io/) 4 | 5 | [![Marketplace Version](http://vsmarketplacebadge.apphb.com/version/spences10.vba-snippets.svg)](https://marketplace.visualstudio.com/items?itemName=spences10.vba-snippets) [![Installs](http://vsmarketplacebadge.apphb.com/installs/spences10.vba-snippets.svg)](https://marketplace.visualstudio.com/items?itemName=spences10.vba-snippets) [![Rating](http://vsmarketplacebadge.apphb.com/rating/spences10.vba-snippets.svg)](https://marketplace.visualstudio.com/items?itemName=spences10.vba-snippets) 6 | 7 | VBA code snippets for VSCode. 8 | This should be used in conjunction with the [VBScript](https://marketplace.visualstudio.com/items?itemName=luggage66.VBScript) extension as the language for VSCode 9 | 10 | 11 | - [Snippets](#snippets) 12 | - [Basic code](#basic-code) 13 | - [Installation](#installation) 14 | - [Contacts](#contacts) 15 | - [Links](#links) 16 | 17 | 18 | 19 | ## Snippets 20 | 21 | ### Basic code 22 | * dim declarations 23 | * if/else 24 | * for/while 25 | * sub/function with errHandler 26 | * case 27 | 28 | ## Installation 29 | Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter. 30 | ``` 31 | ext install vba-snippets 32 | ``` 33 | 34 | ## Contributing 35 | Please fork this repository and contribute back using pull requests. 36 | 37 | Any contributions, large or small, major features, bugfixes and integration tests are welcomed and appreciated but will be thoroughly reviewed and discussed. 38 | 39 | ## Contacts 40 | You can contact me in the following ways: 41 | - Mail : [spences10apps@gmail.com](mailto:spences10apps@gmail.com) 42 | - Github : [spences10](https://github.com/spences10) 43 | 44 | ## Links 45 | - [Source Code](https://github.com/spences10/vba-snippets) 46 | - [Market](https://marketplace.visualstudio.com/items/spences10.vba-snippets) -------------------------------------------------------------------------------- /images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/spences10/vba-snippets/d4814f63de610325356239f624ef7556685cd650/images/logo.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vba-snippets", 3 | "publisher": "spences10", 4 | "description": "Code snippets of vba for VSCode.", 5 | "version": "1.0.1", 6 | "icon": "images/logo.png", 7 | "license": "MIT", 8 | "engines": { 9 | "vscode": "0.10.x" 10 | }, 11 | "categories": [ 12 | "Snippets" 13 | ], 14 | "contributes": { 15 | "snippets": [ 16 | { 17 | "language": "vbscript", 18 | "path": "./snippets/vbscript.json" 19 | } 20 | ] 21 | }, 22 | "repository": { 23 | "type": "git", 24 | "url": "https://github.com/spences10/vba-snippets.git" 25 | } 26 | } -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /snippets/vba-snippets.json: -------------------------------------------------------------------------------- 1 | { 2 | // DATA TYPES =================================================== 3 | /* 4 | Boolean 5 | Integer 6 | Long 7 | Single 8 | Double 9 | Currency 10 | Date 11 | String 12 | Object 13 | Variant 14 | */ 15 | 16 | "Boolean": { 17 | "prefix": "Dimb", 18 | "body": [ 19 | "Dim bol${1:varName} As Boolean" 20 | ], 21 | "description": "Boolean declaration" 22 | }, 23 | "Integer": { 24 | "prefix": "Dimi", 25 | "body": [ 26 | "Dim int${1:varName} As Integer" 27 | ], 28 | "description": "Integer declaration" 29 | }, 30 | "Long": { 31 | "prefix": "Diml", 32 | "body": [ 33 | "Dim lng${1:varName} As Long" 34 | ], 35 | "description": "Long declaration" 36 | }, 37 | "Single": { 38 | "prefix": "Dims", 39 | "body": [ 40 | "Dim sng${1:varName} As Single" 41 | ], 42 | "description": "Single declaration" 43 | }, 44 | "Double": { 45 | "prefix": "Dimd", 46 | "body": [ 47 | "Dim dbl${1:varName} As Double" 48 | ], 49 | "description": "Double declaration" 50 | }, 51 | "Currency": { 52 | "prefix": "Dimc", 53 | "body": [ 54 | "Dim cur${1:varName} As Currency" 55 | ], 56 | "description": "Currency declaration" 57 | }, 58 | "Date": { 59 | "prefix": "Dimdt", 60 | "body": [ 61 | "Dim dat${1:varName} As Date" 62 | ], 63 | "description": "Date declaration" 64 | }, 65 | "String": { 66 | "prefix": "Dims", 67 | "body": [ 68 | "Dim str${1:varName} As String" 69 | ], 70 | "description": "String declaration" 71 | }, 72 | "Object": { 73 | "prefix": "Dimo", 74 | "body": [ 75 | "Dim obj${1:varName} As Object" 76 | ], 77 | "description": "Object declaration" 78 | }, 79 | "Variant": { 80 | "prefix": "Dimv", 81 | "body": [ 82 | "Dim bol${1:varName} As Variant" 83 | ], 84 | "description": "Variant declaration" 85 | }, 86 | 87 | // If Else =================================================== 88 | "If": { 89 | "prefix": "Ife", 90 | "body": [ 91 | "If ${1:expression} Then", 92 | "", 93 | " ElseIf ${1:expression} Then", 94 | "", 95 | " Else", 96 | "", 97 | "End If" 98 | ], 99 | "description": "If ElseIf Else code block" 100 | }, 101 | 102 | // Loops =================================================== 103 | 104 | // For Each =================================================== 105 | "ForEach": { 106 | "prefix": "ForE", 107 | "body": [ 108 | "For Each ${1:element} In ${2:group} ", 109 | " ", 110 | "Next ${1:element}" 111 | ], 112 | "description": "For Each code block" 113 | }, 114 | 115 | // Do Loop =================================================== 116 | "DoLoopw": { 117 | "prefix": "DoLoopw", 118 | "body": [ 119 | "Do", 120 | "Exit Do", 121 | "Loop While" 122 | ], 123 | "description": "Do Loop While code block" 124 | }, 125 | // Do Loop =================================================== 126 | "DoLoopu": { 127 | "prefix": "DoLoopu", 128 | "body": [ 129 | "Do", 130 | "Exit Do", 131 | "Loop Until" 132 | ], 133 | "description": "Do Loop Until code block" 134 | }, 135 | // Do While =================================================== 136 | "DoWhile": { 137 | "prefix": "DoWhile", 138 | "body": [ 139 | "Do While ${1:condition}", 140 | "", 141 | "Loop" 142 | ], 143 | "description": "Do While Loop code block" 144 | }, 145 | 146 | // Do Until =================================================== 147 | "DoUntil": { 148 | "prefix": "DoUntil", 149 | "body": [ 150 | "Do Until ${1:condition}", 151 | "", 152 | "Loop" 153 | ], 154 | "description": "Do Until Loop code block" 155 | }, 156 | 157 | // Sub Function =================================================== 158 | "Suberr": { 159 | "prefix": "Suberr", 160 | "body": [ 161 | "Sub ${1:subName}()", 162 | " '// add declarations", 163 | " On Error GoTo catchError", 164 | "exitSub:", 165 | " Exit Sub", 166 | "catchError:", 167 | " '// add error handling", 168 | " GoTo exitSub", 169 | "End Sub" 170 | ], 171 | "description": "Sub code block with error handling" 172 | }, 173 | "Functionerr": { 174 | "prefix": "Functionerr", 175 | "body": [ 176 | "Function ${1:functionName}() As ${2:functionType}", 177 | " '// add declarations", 178 | " On Error GoTo catchError", 179 | "exitFunction:", 180 | " Exit Function", 181 | "catchError:", 182 | " '// add error handling", 183 | " GoTo exitFunction", 184 | "End Function" 185 | ], 186 | "description": "Function code block with error handling" 187 | }, 188 | // Select Case =================================================== 189 | "Selectc": { 190 | "prefix": "Selectc", 191 | "body": [ 192 | "Select Case ${1:testexpression}", 193 | " Case ${2:expressionlist-n}", 194 | " ${3:statements-n}", 195 | " Case Else", 196 | " ${4:elsestatements}", 197 | "End Select" 198 | ], 199 | "description": "Select Case code block" 200 | } 201 | 202 | 203 | } --------------------------------------------------------------------------------