Opening an Excel file from VBA code
Solved
TraderAS
Posted messages
119
Status
Membre
-
pijaku Posted messages 13513 Registration date Status Modérateur Last intervention -
pijaku Posted messages 13513 Registration date Status Modérateur Last intervention -
Hello,
I want to open an Excel file using the following code:
Sub Ouvrir()
Workbooks.Open Filename:="C:\Documents and Settings\Administrateur\Bureau\TRADING\Action.xlsx"
End Sub
However, when I run it, I get this error
==> Incorrect statement outside of a procedure, and it highlights this part in blue:
C:\Documents and Settings\Administrateur\Bureau\TRADING\Action.xlsx
Thank you.
I want to open an Excel file using the following code:
Sub Ouvrir()
Workbooks.Open Filename:="C:\Documents and Settings\Administrateur\Bureau\TRADING\Action.xlsx"
End Sub
However, when I run it, I get this error
==> Incorrect statement outside of a procedure, and it highlights this part in blue:
C:\Documents and Settings\Administrateur\Bureau\TRADING\Action.xlsx
Thank you.
2 réponses
Hello,
In VBA Excel, try this:
Sources
--
Best regards,
Franck P
In VBA Excel, try this:
Sub Open() Dim Path As String, FileName As String Path = "C:\Documents and Settings\Administrator\Desktop\TRADING\" FileName = "Action.xlsx" Workbooks.Open Filename:= Path & FileName End Sub
Sources
--
Best regards,
Franck P