0% found this document useful (0 votes)
8 views2 pages

How To Opened An Excel File Using Vba

Simple guide to use vba codes to open an excel file with or without passowrd

Uploaded by

Lenu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

How To Opened An Excel File Using Vba

Simple guide to use vba codes to open an excel file with or without passowrd

Uploaded by

Lenu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

How to opened an excel file using vba

Public Function OpenExcelFile(strFilePath As String) As Boolean


'References: Add reference to Microsoft Excel Object Library

Dim appExcel As Excel.Application


Dim myWorkbook As Excel.Workbook

Set appExcel = CreateObject("Excel.Application")


Set myWorkbook = appExcel.Workbooks.Open(strFilePath)
appExcel.Visible = True

'Do Something or Just Leave Open

Set appExcel = Nothing


Set myWorkbook = Nothing
Prepared by
[email protected]
End Function
How to opened an excel file using vba
'Usage Example
Sub OpenExcelFile_Example()
Call OpenExcelFile("C:\Users\PC2\Downloads\nletest.xlsx")
End Sub

----------------
usage with password
Workbooks.Open "C:\Users\nlep1\Desktop\myFile.xlsx", , , Password:="test123“

Credit: https://www.automateexcel.com/vba-code-examples/

Prepared by
[email protected]

You might also like