Ctrl+Z |
Undo |
Ctrl+C |
Copy, Paste & Multiple Paste Cut |
Ctrl+F, |
Find, |
Ctrl+P, Ctrl+F4 Alt+F4 |
Print, |
Ctrl+Arrow |
Move to edge of region |
Ctrl+* |
Select |
Ctrl+A |
Select all cells |
Ctrl+Home |
Select A1,
|
Ctrl+Shift+End |
Select from active cell to last cell in used range. |
Ctrl+Shift+Home |
Select from active cell to A1 |
Ctrl+Page
Down |
Move to
the next sheet, |
Ctrl+Tab |
Move to next open workbook |
Ctrl+N |
Open new workbook |
Shift+F11 |
Insert new worksheet |
Shift+F3 |
Paste function window |
=+FunctionName+Ctrl+A |
Insert new function |
Alt+F11 |
Open VBE |
Ctrl+Shift+Enter |
Array formula |
Ctrl+F3, |
Define name, Paste name |
Ctrl+Spacebar
|
Select columns, Select rows |
Ctrl+1, |
Format |
Ctrl+; |
Current |
Welcome to VBA Tips & Tricks. All VBA related information will be posted on this blog. Of late, VBA has been disregarded by many software professionals for .Net, c# and other technologies. This blog will also post articles related to them too Happy reading
Friday, November 9, 2012
Shortcut keys
Convert PowerPoint Presentation PPT to PDF
How to Convert PowerPoint Presentation PPT to PDF using VBA
PDF is always the universal format for sending the files. With lot of versions of MS Office and other Office suites around.
The following snippet converts the Presentation to a PDF and saves in the same folder of the PPT
ActivePresentation.ExportAsFixedFormat ActivePresentation.Path & "\" & ActivePresentation.Name & ".pdf", ppFixedFormatTypePDF, ppFixedFormatIntentPrint
'Get the name of the currently active file. You'll need this when
'toggelinig between two files, and you want to open the old file
'where the data is assembled
Dim OrginialFile
OriginalFile = Application.ActiveWorkbook.Name
'Open new file
Dim MyFile
MyFile = "C:Maria\Myfolder\Myfile.xls"
Workbooks.Open FileName:=MyFile
'Close a file
Dim MyNewFile
MyNewFile = "MyWonderfulFile.xls"
'Unable ScreenUpdating and DisoplayAlerts, so teh user isn't asked if he want tosave the changes
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Windows(MyNewFile).Close
Application.ScreenUpdating = true
Application.DisplayAlerts = true
'Toggle between open files.
Dim AnotherOpenFile
AnotherOpenFile = "MyWounderfullFile.xls"
Windows(AnotherOpenFile ).Activate
'toggelinig between two files, and you want to open the old file
'where the data is assembled
Dim OrginialFile
OriginalFile = Application.ActiveWorkbook.Name
'Open new file
Dim MyFile
MyFile = "C:Maria\Myfolder\Myfile.xls"
Workbooks.Open FileName:=MyFile
'Close a file
Dim MyNewFile
MyNewFile = "MyWonderfulFile.xls"
'Unable ScreenUpdating and DisoplayAlerts, so teh user isn't asked if he want tosave the changes
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Windows(MyNewFile).Close
Application.ScreenUpdating = true
Application.DisplayAlerts = true
'Toggle between open files.
Dim AnotherOpenFile
AnotherOpenFile = "MyWounderfullFile.xls"
Windows(AnotherOpenFile ).Activate
DeletePivotTables
Sub DeletePivotTables()
Dim Pt As PivotTable
Dim Ws As Worksheet
'Loop through worksheets
For Each Ws In ActiveWorkbook.Worksheets
Worksheets(Ws.Name).Select
'Loop through pivot tables
For Each Pt In Ws.PivotTables
'Delete pivot table
Pt.PivotSelect "", xlDataAndLabel, True
Selection.Delete Shift:=xlToLeft
'Exit Sub 'Optional: Get out
Next Pt
Next Ws
End Sub
Dim Pt As PivotTable
Dim Ws As Worksheet
'Loop through worksheets
For Each Ws In ActiveWorkbook.Worksheets
Worksheets(Ws.Name).Select
'Loop through pivot tables
For Each Pt In Ws.PivotTables
'Delete pivot table
Pt.PivotSelect "", xlDataAndLabel, True
Selection.Delete Shift:=xlToLeft
'Exit Sub 'Optional: Get out
Next Pt
Next Ws
End Sub
Check Extension
Sub CheckExtn()
Dim MinExtensionX
Dim Arr() As Variant
Dim lngLoc As Variant
'Retrieve extension of file
MinExtensionX = Mid(MyFile.Name, InStrRev(MyFile.Name, ".") + 1)
Arr = Array("xls", "xlsx") 'define which extensions you want to allow
On Error Resume Next
lngLoc = Application.WorksheetFunction.Match(MinExtensionX, Arr(), 0)
If Not IsEmpty(lngLoc) Then '
'DO STUFF if it's an xls/xlsx file. Otherwise, chose next file in folder
End If
Subscribe to:
Posts (Atom)