Excel VBA
Excel VBA
This free excel macro allows you to open any program on your computer from excel. You can
open a media player, file viewer, image editor, internet browser, PowerPoint, Word, Outlook, or
any other program on your computer. This is a really useful macro to, in essence, combine
excel's functionality with that of another program. The vba code below can be used on its own or
integrated into an existing macro in order to open some other program on your computer. This
macro uses a Shell Command to open a program. Note: To use this macro to open a program on
your computer, you must enter the full file path to the program's executable file. So, you need to
enter the file path from the hard drive through all the folders up to the file. Also, each executable
file will end in a ".exe" file format; don't forget to include that extension in the macro as well.
To change the file path and extension to point to the location of your program's executable file,
simply change this line of code within the excel macro Shell ("C:\TEST\TEST.exe"). Change
the file path which is between the quotation marks to whatever your file path is.
Where to install the macro: Module
8. Close the Microsoft Visual Basic Editor window and save the Excel file. When you
close the Visual Basic Editor window, the regular Excel window will not close.
9. You are now ready to run the macro.
Print Preview
Private Sub CommandButton1_Click()
'Show the print preview window for the entire active Excel workbook or file
Worksheets("Sunrich BILL 216").PrintPreview
End Sub
Print
Private Sub CommandButton2_Click()
ActiveSheet.PrintOut
End Sub
End Sub
To copy sheets in a work book
Private Sub CommandButton2_Click()
Worksheets("Sheet1").Copy After:=Worksheets("Sheet3")
End Sub
To Move sheets in a work book
End Sub
Activate sheets
Sheets("sheet1").Activate
Print Selection
'Print only the selection
Selection.PrintOut
Print A Range
'Print range A1:C6
Range("A1:C6").PrintOut
Print preview
'Active sheet print preview
ActiveSheet.PrintOut preview:=True