SlideShare una empresa de Scribd logo
1 de 22
Getting
Started with
the Visual
Basic Editor
Ade Tiara Putri
Program Studi S1 Sistem Informasi
Fakultas Sains dan Teknologi
Universitas Islam Negeri Sultan Syarif Kasim Riau
http://sif.uin-suska.ac.id/
http://fst.uin-suska.ac.id/
http://www.uin-suska.ac.id/
Opening the Visual Basic
Editor with a Macro Selected
Opening the Visual Basic Editor
1. Open Word if it’s not already
running.
2. Press Alt+F8 to display the
Macros dialog box.
3. Select the
Transpose_Word_Right macro and
click the Edit button. Word opens
the
Visual Basic Editor with the macro
displayed and ready for editing,
4. Choose File ➢ Close to close
the Visual Basic Editor for the
moment so that you can open
it using the method described in
the next section.
1
Code window
Properties window
Project Explorer
Opening the Visual Basic Editor
Directly
1. Open or activate
the host application.
In this case, open or
switch to Word.
2. Press Alt+F11.
The Visual Basic
Editor opens.
2
Using the Visual Basic Editor’s
Main Windows
The Project Explorer
View Code
Toggle Folders
View Object
The Project Explorer is the tool for navigating among the
various objects in the Visual Basic
Editor.
View
Code
•Displays the Code window for the selected
objec
View
Object
•Displays a window containing
the selected object. T
Toggle
Folders
• Toggles the view of the objects in the
Project Explorer between folder view
and contents view
Depending on the host application and its capabilities, each project can contain
some or all of the following elements.
User forms (windows that make up part of the macro’s user
interface, such as a custom dialog box that accepts user input).
Modules containing macros, procedures, and functions.
Class modules (specialized modules that defi ne objects,
their properties, and their values).
References to other projects or to library fi les (such as DLLs—
Dynamic Link Libraries).
Objects related to the application.
The Object Browser
The Visual Basic Editor provides a full Object Browser for working with objects in
VBA. You’ll look at the Object Browser in detail in Chapter 8, “Finding the Objects,
Methods, and Properties You Need,” and when you examine the object models for the
various Office applications in the final part of this book.
The Document object is selected in the left-hand panel, and a list of its
properties appears in the right-hand panel. (To see this in your VBA Editor,
press F2.)
The Code Window
Complete
Word
• The Complete Word feature can complete the word you’re typing into the Code window, once you’ve typed
enough letters to distinguish that word from any other. If you haven’t typed enough letters to distinguish the
word, the Visual Basic Editor gives you the closest possibilities. You can either “type down” (continue typing to
narrow the selection) or scroll through the displayed list to fi nd the one you want.
Clear All Bookmarks
Previous Bookmark
Next Bookmark
Toggle Bookmark
Uncomment Block
Comment Block
Toggle Breakpoint
Outdent
Indent
Complete Word
Parameter Info
Quick Info
List Constants
List Properties/Methods
Quick Info
• The Complete Word feature can complete the word you’re typing into the Code window, once you’ve typed enough letters to
distinguish that word from any other. If you haven’t typed enough letters to distinguish the word, the Visual Basic Editor gives you
the closest possibilities. You can either “type down” (continue typing to narrow the selection) or scroll through the displayed list to
fi nd the one you want. The Quick Info feature displays a ScreenTip showing syntax information about the currently selected
variable, function, method, command, or sub. (Selected here just means the word in the code that’s under or adjacent to the
blinking cursor insertion point.) If you type in a command like MsgBox and then press the spacebar, the ScreenTip pops up to help
you complete typing in the command. The tip shows both the required and optional elements of that command. Optional
elements are enclosed in square brackets.
If you’re typing in
actual commands from
the VBA language, the
easiest way to see
Quick Info is just to
type the command’s
name and then press
the spacebar key
Position the insertion
point in the term and
choose Edit ➢ Quick
Info.
Position the insertion
point in the command
and press Ctrl+I.
Right-click a VB
command and choose
Quick Info from the
shortcut menu.
Click the Quick Info
icon on the Edit
toolbar.
Just type a space
following a VB
command. For
example, type msgbox
(space).
To display Quick Info, use one of these methods:
Auto List
Members
• Many VB commands have properties (qualities) and methods (behaviors). Taken together, the properties
and methods of an object are called its members. The Auto List Members list allows you to quickly complete the
line of code. Auto List Members is switched on by default and is automatically displayed when you type a period
in an object description or a comma, parentheses, or other punctuation in a line of code. Notice in Figure 2.10
that I’ve typed in a message-box command followed by the text Hello, Marvin! and then a comma. As soon as I
typed the comma, the list of settings for the Buttons appeared. (These settings are called constants.)
2
a. Press Tab, or double-click the property or method, if you want to continue adding to
this line of code after entering the property or method.
b. Press Enter if you want to start a new line after entering the property or method.
1
Press the down-arrow key to scroll down to the property or method, or scroll down with the mouse. You can also type the fi
rst few letters of the property or method’s name to jump to it.
To use Auto List Members to insert your choice into your
code, follow these steps
List
Constants
• The List Constants feature displays a pop-up list box containing constants for a property you’ve
• typed so that you can quickly complete the expression. List Constants is switched on by default.
• Alternatively, you can display the list box by clicking the List Constants button on the Edit
• toolbar.
1. Type Assistant.Animation = in the
Code window.
2. Press the ↓ (down-arrow) to scroll
down to the constant you’re after, or
type its fi rst letter (or fi rst few
letters), or scroll down with the
mouse.
3. Enter the constant in the code by
doing the following:
• Press Tab, or double-click the constant,
if you want to continue working on the
same line after entering the constant.
• Press Enter if you want to start a new
line after entering the constant.
Setting Properties for a Project
Set the project name in the Project Name text box. This name identifi es the project in the Object Browser and, when
necessary, in the Windows Registry. Make sure the name is unique to avoid confusion with any other project.
Enter a description of the project in the Project Description text box. This description appears in the Description pane in
the Object Browser to help the user understand what the project is. So be as concise, yet descriptive, as possible.
Designate the Help fi le for the project by entering the name and path of the Help fi le in the Help File Name text box. Click
the button marked with the ellipsis (…) to the right of the Help File Name text box to display the Help File dialog box. Then
select the fi le and click the Open button to enter the name of the Help fi le in the text box.
Specify the Help context for the project in the Project Help Context ID text box. The Help context refers to a location in the
Help fi le
Specify any conditional compilation arguments needed for the project. Some fi nd conditional compilation useful, but most
don’t.
Here’s what you can do on the General tab of the Project Properties dialog box
Customizing the Visual Basic
Editor
Choose Editor and
View preference
settings in the
Visual Basic Editor
to control how it
interacts with you.
Choose which
windows to display
in the Visual Basic
Editor, and
organize their
layout so you can
use your
workspace as
effectively as
possible.
Customize the
toolbar and menus
in the Visual Basic
Editor so the
commands you
need are at hand
(without cluttering
up your
workspace).
Customize the
Toolbox so it
contains the tools
you need to build
your user forms.
Given how much time you’re likely to spend in the Visual Basic Editor, you ought to customize it
so you can work as efficiently and comfortably as possible. You can customize it as follows:
Choosing Editor and View Preferences
Auto Syntax Check Controls whether VBA displays warning message boxes when it discovers errors while
Automatically Checking Your syntax As You type Lines of code.
Require Variable Declaration Governs whether you must declare variables explicitly
Auto List Members Described earlier in this chapter, this option controls whether the Auto List Members and
List Constants features automatically suggest properties, methods, and constants as you work in the Code
window.
Auto quick info this option controls whether the quick info feature automatically displays information about
functions and their parameters as you work with functions in the code window.
Auto Data Tips This option controls whether the Visual Basic Editor displays ScreenTips when you hover the
mouse pointer over a variable or expression in Break mode, enabling you to check the value of a variable or
expression quickly.
Auto Indent Determines whether the Visual Basic Editor automatically indents subsequent Lines Of Code After
you’ve Indented a line. When Auto Indent Switched on, The Visual Basic Editor Starts Each new line Of Code
Indented to the Same Level (the Same Number Of Tabs or spaces or the Same Combination Of The two) as The
Previous line.
Tab Width Sets the number of spaces in a tab.
Drag-And-Drop Text Editing Controls whether the Visual Basic Editor supports dragand-drop.
Default To Full Module View Controls whether the Visual Basic Editor displays all the procedures
in a module in one list (Full Module view) or displays them one at a time (Procedure view).
Procedure Separator Controls whether the Visual Basic Editor displays horizontal lines to separate
the procedures within a module shown in Full Module view in the Code window.
Editor Format Page Options
Normal Text Takes care of much of the text in a typical procedure. You’ll
probably want to make this a conventional color (such as black, the
default).
Selection Text Affects the color of selected (highlighted) text.
Syntax Error Text Affects the color VBA uses for offending lines. The
default color is red.
Execution Point Text Affects the color VBA uses for the line currently
being executed in Break mode.
Breakpoint Text Affects the color in which VBA displays breakpoints
(points where code execution is forced to stop).
Comment Text Affects the color of comment lines. The default color is
dark green.
Keyword Text Affects the color of keywords (words recognized as part of
the VBA language).
Identifi er Text Affects the color VBA uses for identifiers. Identifiers
include the names of variables, constants, and procedures you define.
Bookmark Text Affects the color VBA uses for the bookmarks in your
code.
Call Return Text Affects the color VBA uses for calls to other procedures.
By default, the Visual Basic Editor uses lime green for call return text.
General Page Options
Form Grid
Settings
Group Box
Edit and
Continue
Group Box
Error
Trapping
Group Box
• Break On All Errors
• Break In Class
Module
• Break On
Unhandled Errors
Compile
Group Box
Show
ToolTips and
Collapse Proj.
Hides
Windows
Docking Page Options
The Docking page of the Options dialog box, controls
whether the various windows in the Visual Basic Editor
are dockable—that is, whether they snap automatically
and magnetically to a side of the window when you
move them there. Keeping windows dockable usually
makes for a more organized interface. However, you
may want to make the windows undockable so you can
drag them outside the Visual Basic Editor if necessary
and arrange them as you like on the screen.
Contemporary monitors are becoming quite large, so
you might have plenty of room to display various
windows outside the primary Editor window.
Choosing and Laying Out the Editor Windows
Always make the Code window large—maximize it within
the Editor. If you write long lines of code, you’ll want to
have as much space in the Visual Basic Editor window as
possible. That way your lines won’t wrap and the code will
be easier to read.
Some people fi nd that much of the time they’re actively
writing code, they can dispense with the Project Explorer,
displaying it only when needed. As a handy way of restoring
it, you can put the Project Explorer display command on the
Code window, Code window break, Watch window,
Immediate window, and Locals window context menus.
(You’ll learn how to customize the Editor’s menus in the
next section.) You can also quickly display the Project
Explorer by pressing its shortcut key, Ctrl+R.
Customizing the Toolbar and Menu Bar
There are no menus at all in Word, Excel, Access,
and the other Offi ce applications. And the lone
toolbar is the Quick Access Toolbar. The Ribbon
replaced menus and most toolbars back in 2007.
But the Visual Basic Editor retains the older
interface style—no Ribbon, but instead the classic
menus and toolbars, and you can customize them
to a limited extent. To do this, choose View ➢
Toolbars ➢ Customize (or right-click a toolbar or
the menu bar and choose Customize from the
context menu).
Customizing the Toolbox
Adding Controls to the Toolbox
• Right-click in the Toolbox page (not the tab
itself) where you want to add controls. (You’ll
learn how to add new pages to the Toolbox in
the section “Adding Pages to the Toolbox” a
little later in this chapter.)
• Choose Additional Controls from the context
menu to display the Additional Controls
dialog box.
• In the Available Controls list box, click the
check boxes for the controls you want to add
to the Toolbox, and then click the OK button.
The Bottom Line
– Open the Visual Basic Editor. When you want to create a new macro by hand-programming (as opposed to
recording) or need to modify or test a macro, the Visual Basic Editor is a powerful tool.
Master It Open the Visual Basic Editor in Word and create a simple macro.
– Open a macro in the Visual Basic Editor. You edit and test macro code in the Code window Of the Visual Basic
Editor.
Master It Open the Visual Basic Editor and display a particular macro in the Code window.
– Understand the Project Explorer’s two views. The Project Explorer window displays a tree of current projects.
You can choose between viewing only the files or the folders and fi les.
Master It Switch between folder and contents view in the Project Explorer.
– Set properties for a project. You can specify a project’s name, an associated Help fi le, and other qualities of a
project.
Master It Lock a project so others can’t modify or even read its contents.
– Customize the Visual Basic Editor. The Visual Basic Editor can be customized in many ways, including
personalizing classic menus and toolbars.
Master It Undock the Properties window and change its size. Then redock it.
“ Thank You”
Source : Mastering VBA for Microsoft Office 2016 by Richard Mansfi eld’s (2016)

Más contenido relacionado

La actualidad más candente

Transforming Power Point Show with VBA
Transforming Power Point Show with VBATransforming Power Point Show with VBA
Transforming Power Point Show with VBADCPS
 
Intro macros in Excel 2007
Intro macros in Excel 2007Intro macros in Excel 2007
Intro macros in Excel 2007Hasrudin Tazep
 
Access tips access and sql part 6 dynamic reports
Access tips  access and sql part 6  dynamic reportsAccess tips  access and sql part 6  dynamic reports
Access tips access and sql part 6 dynamic reportsquest2900
 
A Quick Simple MS Excel Macro
A Quick Simple MS Excel MacroA Quick Simple MS Excel Macro
A Quick Simple MS Excel MacroPranav Ghode
 
Create formsexcel
Create formsexcelCreate formsexcel
Create formsexcelRavi Gajul
 
Access tips access and sql part 5 more instant queries 1
Access tips  access and sql part 5  more instant queries 1Access tips  access and sql part 5  more instant queries 1
Access tips access and sql part 5 more instant queries 1quest2900
 
Welcome to word template
Welcome to word templateWelcome to word template
Welcome to word templateInRai1
 
The visual studio start page is shown in the figure below
The visual studio start page is shown in the figure belowThe visual studio start page is shown in the figure below
The visual studio start page is shown in the figure belowTan Ps
 
How to apply a formula and macro in excel......by irfan afzal
How to apply a formula and macro in excel......by irfan afzalHow to apply a formula and macro in excel......by irfan afzal
How to apply a formula and macro in excel......by irfan afzal1995786
 
Computer homework
Computer homeworkComputer homework
Computer homeworkadarsh-kaul
 
Android Homework for-july-19th-2015
Android Homework for-july-19th-2015Android Homework for-july-19th-2015
Android Homework for-july-19th-2015Rishi Kumar
 
Microsoft word -_microsoft_word_exercise
Microsoft word -_microsoft_word_exerciseMicrosoft word -_microsoft_word_exercise
Microsoft word -_microsoft_word_exerciseSubeesh Up
 
Form4 cd4
Form4 cd4Form4 cd4
Form4 cd4smktsj2
 
Micro soft word,excel notes
Micro soft word,excel notesMicro soft word,excel notes
Micro soft word,excel notesImran Waris
 
Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6Jeanie Arnoco
 
Ten hot tips for type (i.c.t. report)
Ten hot tips for type (i.c.t. report)Ten hot tips for type (i.c.t. report)
Ten hot tips for type (i.c.t. report)LalaineG_07
 
Html Xhtml And Xml 3e Tutorial 6
Html Xhtml And Xml 3e Tutorial 6Html Xhtml And Xml 3e Tutorial 6
Html Xhtml And Xml 3e Tutorial 6larsonsb
 
Pks ms excel unit 2_bcomcs
Pks ms excel unit 2_bcomcsPks ms excel unit 2_bcomcs
Pks ms excel unit 2_bcomcsKALAISELVI P
 
Lecture 6: introduction to computer
Lecture 6: introduction to computerLecture 6: introduction to computer
Lecture 6: introduction to computerSultan Omar Shige
 

La actualidad más candente (20)

Transforming Power Point Show with VBA
Transforming Power Point Show with VBATransforming Power Point Show with VBA
Transforming Power Point Show with VBA
 
Intro macros in Excel 2007
Intro macros in Excel 2007Intro macros in Excel 2007
Intro macros in Excel 2007
 
Access tips access and sql part 6 dynamic reports
Access tips  access and sql part 6  dynamic reportsAccess tips  access and sql part 6  dynamic reports
Access tips access and sql part 6 dynamic reports
 
A Quick Simple MS Excel Macro
A Quick Simple MS Excel MacroA Quick Simple MS Excel Macro
A Quick Simple MS Excel Macro
 
Create formsexcel
Create formsexcelCreate formsexcel
Create formsexcel
 
Word
WordWord
Word
 
Access tips access and sql part 5 more instant queries 1
Access tips  access and sql part 5  more instant queries 1Access tips  access and sql part 5  more instant queries 1
Access tips access and sql part 5 more instant queries 1
 
Welcome to word template
Welcome to word templateWelcome to word template
Welcome to word template
 
The visual studio start page is shown in the figure below
The visual studio start page is shown in the figure belowThe visual studio start page is shown in the figure below
The visual studio start page is shown in the figure below
 
How to apply a formula and macro in excel......by irfan afzal
How to apply a formula and macro in excel......by irfan afzalHow to apply a formula and macro in excel......by irfan afzal
How to apply a formula and macro in excel......by irfan afzal
 
Computer homework
Computer homeworkComputer homework
Computer homework
 
Android Homework for-july-19th-2015
Android Homework for-july-19th-2015Android Homework for-july-19th-2015
Android Homework for-july-19th-2015
 
Microsoft word -_microsoft_word_exercise
Microsoft word -_microsoft_word_exerciseMicrosoft word -_microsoft_word_exercise
Microsoft word -_microsoft_word_exercise
 
Form4 cd4
Form4 cd4Form4 cd4
Form4 cd4
 
Micro soft word,excel notes
Micro soft word,excel notesMicro soft word,excel notes
Micro soft word,excel notes
 
Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6Introduction to programming using Visual Basic 6
Introduction to programming using Visual Basic 6
 
Ten hot tips for type (i.c.t. report)
Ten hot tips for type (i.c.t. report)Ten hot tips for type (i.c.t. report)
Ten hot tips for type (i.c.t. report)
 
Html Xhtml And Xml 3e Tutorial 6
Html Xhtml And Xml 3e Tutorial 6Html Xhtml And Xml 3e Tutorial 6
Html Xhtml And Xml 3e Tutorial 6
 
Pks ms excel unit 2_bcomcs
Pks ms excel unit 2_bcomcsPks ms excel unit 2_bcomcs
Pks ms excel unit 2_bcomcs
 
Lecture 6: introduction to computer
Lecture 6: introduction to computerLecture 6: introduction to computer
Lecture 6: introduction to computer
 

Similar a Getting started with the visual basic editor

Similar a Getting started with the visual basic editor (20)

Word
WordWord
Word
 
Vb%20 tutorial
Vb%20 tutorialVb%20 tutorial
Vb%20 tutorial
 
Mca 504 dotnet_unit5
Mca 504 dotnet_unit5Mca 504 dotnet_unit5
Mca 504 dotnet_unit5
 
Visual C# 2010
Visual C# 2010Visual C# 2010
Visual C# 2010
 
Notacd04
Notacd04Notacd04
Notacd04
 
Notacd04
Notacd04Notacd04
Notacd04
 
Visual Programming
Visual ProgrammingVisual Programming
Visual Programming
 
Microsoft word features
Microsoft word featuresMicrosoft word features
Microsoft word features
 
Visual Basic IDE Introduction
Visual Basic IDE IntroductionVisual Basic IDE Introduction
Visual Basic IDE Introduction
 
Visual Basic IDE Intro.pdf
Visual Basic IDE Intro.pdfVisual Basic IDE Intro.pdf
Visual Basic IDE Intro.pdf
 
Autocad excel vba
Autocad excel vbaAutocad excel vba
Autocad excel vba
 
Visual basic concepts
Visual basic conceptsVisual basic concepts
Visual basic concepts
 
Chapter 01
Chapter 01Chapter 01
Chapter 01
 
Visual basic
Visual basicVisual basic
Visual basic
 
MS Word
MS WordMS Word
MS Word
 
Task 2
Task 2Task 2
Task 2
 
Visual Basic.pptx
Visual Basic.pptxVisual Basic.pptx
Visual Basic.pptx
 
Unit2
Unit2Unit2
Unit2
 
Microsoft® office word 2003 a
Microsoft® office word 2003 aMicrosoft® office word 2003 a
Microsoft® office word 2003 a
 
Vb6.0 intro
Vb6.0 introVb6.0 intro
Vb6.0 intro
 

Último

Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptrcbcrtm
 

Último (20)

Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Odoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting ServiceOdoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting Service
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.ppt
 

Getting started with the visual basic editor

  • 1. Getting Started with the Visual Basic Editor Ade Tiara Putri Program Studi S1 Sistem Informasi Fakultas Sains dan Teknologi Universitas Islam Negeri Sultan Syarif Kasim Riau http://sif.uin-suska.ac.id/ http://fst.uin-suska.ac.id/ http://www.uin-suska.ac.id/
  • 2. Opening the Visual Basic Editor with a Macro Selected Opening the Visual Basic Editor 1. Open Word if it’s not already running. 2. Press Alt+F8 to display the Macros dialog box. 3. Select the Transpose_Word_Right macro and click the Edit button. Word opens the Visual Basic Editor with the macro displayed and ready for editing, 4. Choose File ➢ Close to close the Visual Basic Editor for the moment so that you can open it using the method described in the next section. 1 Code window Properties window Project Explorer
  • 3. Opening the Visual Basic Editor Directly 1. Open or activate the host application. In this case, open or switch to Word. 2. Press Alt+F11. The Visual Basic Editor opens. 2
  • 4. Using the Visual Basic Editor’s Main Windows The Project Explorer View Code Toggle Folders View Object The Project Explorer is the tool for navigating among the various objects in the Visual Basic Editor. View Code •Displays the Code window for the selected objec View Object •Displays a window containing the selected object. T Toggle Folders • Toggles the view of the objects in the Project Explorer between folder view and contents view
  • 5. Depending on the host application and its capabilities, each project can contain some or all of the following elements. User forms (windows that make up part of the macro’s user interface, such as a custom dialog box that accepts user input). Modules containing macros, procedures, and functions. Class modules (specialized modules that defi ne objects, their properties, and their values). References to other projects or to library fi les (such as DLLs— Dynamic Link Libraries). Objects related to the application.
  • 6. The Object Browser The Visual Basic Editor provides a full Object Browser for working with objects in VBA. You’ll look at the Object Browser in detail in Chapter 8, “Finding the Objects, Methods, and Properties You Need,” and when you examine the object models for the various Office applications in the final part of this book. The Document object is selected in the left-hand panel, and a list of its properties appears in the right-hand panel. (To see this in your VBA Editor, press F2.)
  • 7. The Code Window Complete Word • The Complete Word feature can complete the word you’re typing into the Code window, once you’ve typed enough letters to distinguish that word from any other. If you haven’t typed enough letters to distinguish the word, the Visual Basic Editor gives you the closest possibilities. You can either “type down” (continue typing to narrow the selection) or scroll through the displayed list to fi nd the one you want. Clear All Bookmarks Previous Bookmark Next Bookmark Toggle Bookmark Uncomment Block Comment Block Toggle Breakpoint Outdent Indent Complete Word Parameter Info Quick Info List Constants List Properties/Methods
  • 8. Quick Info • The Complete Word feature can complete the word you’re typing into the Code window, once you’ve typed enough letters to distinguish that word from any other. If you haven’t typed enough letters to distinguish the word, the Visual Basic Editor gives you the closest possibilities. You can either “type down” (continue typing to narrow the selection) or scroll through the displayed list to fi nd the one you want. The Quick Info feature displays a ScreenTip showing syntax information about the currently selected variable, function, method, command, or sub. (Selected here just means the word in the code that’s under or adjacent to the blinking cursor insertion point.) If you type in a command like MsgBox and then press the spacebar, the ScreenTip pops up to help you complete typing in the command. The tip shows both the required and optional elements of that command. Optional elements are enclosed in square brackets. If you’re typing in actual commands from the VBA language, the easiest way to see Quick Info is just to type the command’s name and then press the spacebar key Position the insertion point in the term and choose Edit ➢ Quick Info. Position the insertion point in the command and press Ctrl+I. Right-click a VB command and choose Quick Info from the shortcut menu. Click the Quick Info icon on the Edit toolbar. Just type a space following a VB command. For example, type msgbox (space). To display Quick Info, use one of these methods:
  • 9. Auto List Members • Many VB commands have properties (qualities) and methods (behaviors). Taken together, the properties and methods of an object are called its members. The Auto List Members list allows you to quickly complete the line of code. Auto List Members is switched on by default and is automatically displayed when you type a period in an object description or a comma, parentheses, or other punctuation in a line of code. Notice in Figure 2.10 that I’ve typed in a message-box command followed by the text Hello, Marvin! and then a comma. As soon as I typed the comma, the list of settings for the Buttons appeared. (These settings are called constants.) 2 a. Press Tab, or double-click the property or method, if you want to continue adding to this line of code after entering the property or method. b. Press Enter if you want to start a new line after entering the property or method. 1 Press the down-arrow key to scroll down to the property or method, or scroll down with the mouse. You can also type the fi rst few letters of the property or method’s name to jump to it. To use Auto List Members to insert your choice into your code, follow these steps
  • 10. List Constants • The List Constants feature displays a pop-up list box containing constants for a property you’ve • typed so that you can quickly complete the expression. List Constants is switched on by default. • Alternatively, you can display the list box by clicking the List Constants button on the Edit • toolbar. 1. Type Assistant.Animation = in the Code window. 2. Press the ↓ (down-arrow) to scroll down to the constant you’re after, or type its fi rst letter (or fi rst few letters), or scroll down with the mouse. 3. Enter the constant in the code by doing the following: • Press Tab, or double-click the constant, if you want to continue working on the same line after entering the constant. • Press Enter if you want to start a new line after entering the constant.
  • 11. Setting Properties for a Project Set the project name in the Project Name text box. This name identifi es the project in the Object Browser and, when necessary, in the Windows Registry. Make sure the name is unique to avoid confusion with any other project. Enter a description of the project in the Project Description text box. This description appears in the Description pane in the Object Browser to help the user understand what the project is. So be as concise, yet descriptive, as possible. Designate the Help fi le for the project by entering the name and path of the Help fi le in the Help File Name text box. Click the button marked with the ellipsis (…) to the right of the Help File Name text box to display the Help File dialog box. Then select the fi le and click the Open button to enter the name of the Help fi le in the text box. Specify the Help context for the project in the Project Help Context ID text box. The Help context refers to a location in the Help fi le Specify any conditional compilation arguments needed for the project. Some fi nd conditional compilation useful, but most don’t. Here’s what you can do on the General tab of the Project Properties dialog box
  • 12. Customizing the Visual Basic Editor Choose Editor and View preference settings in the Visual Basic Editor to control how it interacts with you. Choose which windows to display in the Visual Basic Editor, and organize their layout so you can use your workspace as effectively as possible. Customize the toolbar and menus in the Visual Basic Editor so the commands you need are at hand (without cluttering up your workspace). Customize the Toolbox so it contains the tools you need to build your user forms. Given how much time you’re likely to spend in the Visual Basic Editor, you ought to customize it so you can work as efficiently and comfortably as possible. You can customize it as follows:
  • 13. Choosing Editor and View Preferences Auto Syntax Check Controls whether VBA displays warning message boxes when it discovers errors while Automatically Checking Your syntax As You type Lines of code. Require Variable Declaration Governs whether you must declare variables explicitly Auto List Members Described earlier in this chapter, this option controls whether the Auto List Members and List Constants features automatically suggest properties, methods, and constants as you work in the Code window. Auto quick info this option controls whether the quick info feature automatically displays information about functions and their parameters as you work with functions in the code window. Auto Data Tips This option controls whether the Visual Basic Editor displays ScreenTips when you hover the mouse pointer over a variable or expression in Break mode, enabling you to check the value of a variable or expression quickly. Auto Indent Determines whether the Visual Basic Editor automatically indents subsequent Lines Of Code After you’ve Indented a line. When Auto Indent Switched on, The Visual Basic Editor Starts Each new line Of Code Indented to the Same Level (the Same Number Of Tabs or spaces or the Same Combination Of The two) as The Previous line.
  • 14. Tab Width Sets the number of spaces in a tab. Drag-And-Drop Text Editing Controls whether the Visual Basic Editor supports dragand-drop. Default To Full Module View Controls whether the Visual Basic Editor displays all the procedures in a module in one list (Full Module view) or displays them one at a time (Procedure view). Procedure Separator Controls whether the Visual Basic Editor displays horizontal lines to separate the procedures within a module shown in Full Module view in the Code window.
  • 15. Editor Format Page Options Normal Text Takes care of much of the text in a typical procedure. You’ll probably want to make this a conventional color (such as black, the default). Selection Text Affects the color of selected (highlighted) text. Syntax Error Text Affects the color VBA uses for offending lines. The default color is red. Execution Point Text Affects the color VBA uses for the line currently being executed in Break mode. Breakpoint Text Affects the color in which VBA displays breakpoints (points where code execution is forced to stop). Comment Text Affects the color of comment lines. The default color is dark green. Keyword Text Affects the color of keywords (words recognized as part of the VBA language). Identifi er Text Affects the color VBA uses for identifiers. Identifiers include the names of variables, constants, and procedures you define. Bookmark Text Affects the color VBA uses for the bookmarks in your code. Call Return Text Affects the color VBA uses for calls to other procedures. By default, the Visual Basic Editor uses lime green for call return text.
  • 16. General Page Options Form Grid Settings Group Box Edit and Continue Group Box Error Trapping Group Box • Break On All Errors • Break In Class Module • Break On Unhandled Errors Compile Group Box Show ToolTips and Collapse Proj. Hides Windows
  • 17. Docking Page Options The Docking page of the Options dialog box, controls whether the various windows in the Visual Basic Editor are dockable—that is, whether they snap automatically and magnetically to a side of the window when you move them there. Keeping windows dockable usually makes for a more organized interface. However, you may want to make the windows undockable so you can drag them outside the Visual Basic Editor if necessary and arrange them as you like on the screen. Contemporary monitors are becoming quite large, so you might have plenty of room to display various windows outside the primary Editor window.
  • 18. Choosing and Laying Out the Editor Windows Always make the Code window large—maximize it within the Editor. If you write long lines of code, you’ll want to have as much space in the Visual Basic Editor window as possible. That way your lines won’t wrap and the code will be easier to read. Some people fi nd that much of the time they’re actively writing code, they can dispense with the Project Explorer, displaying it only when needed. As a handy way of restoring it, you can put the Project Explorer display command on the Code window, Code window break, Watch window, Immediate window, and Locals window context menus. (You’ll learn how to customize the Editor’s menus in the next section.) You can also quickly display the Project Explorer by pressing its shortcut key, Ctrl+R.
  • 19. Customizing the Toolbar and Menu Bar There are no menus at all in Word, Excel, Access, and the other Offi ce applications. And the lone toolbar is the Quick Access Toolbar. The Ribbon replaced menus and most toolbars back in 2007. But the Visual Basic Editor retains the older interface style—no Ribbon, but instead the classic menus and toolbars, and you can customize them to a limited extent. To do this, choose View ➢ Toolbars ➢ Customize (or right-click a toolbar or the menu bar and choose Customize from the context menu).
  • 20. Customizing the Toolbox Adding Controls to the Toolbox • Right-click in the Toolbox page (not the tab itself) where you want to add controls. (You’ll learn how to add new pages to the Toolbox in the section “Adding Pages to the Toolbox” a little later in this chapter.) • Choose Additional Controls from the context menu to display the Additional Controls dialog box. • In the Available Controls list box, click the check boxes for the controls you want to add to the Toolbox, and then click the OK button.
  • 21. The Bottom Line – Open the Visual Basic Editor. When you want to create a new macro by hand-programming (as opposed to recording) or need to modify or test a macro, the Visual Basic Editor is a powerful tool. Master It Open the Visual Basic Editor in Word and create a simple macro. – Open a macro in the Visual Basic Editor. You edit and test macro code in the Code window Of the Visual Basic Editor. Master It Open the Visual Basic Editor and display a particular macro in the Code window. – Understand the Project Explorer’s two views. The Project Explorer window displays a tree of current projects. You can choose between viewing only the files or the folders and fi les. Master It Switch between folder and contents view in the Project Explorer. – Set properties for a project. You can specify a project’s name, an associated Help fi le, and other qualities of a project. Master It Lock a project so others can’t modify or even read its contents. – Customize the Visual Basic Editor. The Visual Basic Editor can be customized in many ways, including personalizing classic menus and toolbars. Master It Undock the Properties window and change its size. Then redock it.
  • 22. “ Thank You” Source : Mastering VBA for Microsoft Office 2016 by Richard Mansfi eld’s (2016)