Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Syntax error in opening Excel file.

Status
Not open for further replies.

laks143

Programmer
Apr 20, 2009
20
GB
Hi
I am trying to open an excel through Excel VBA.
I am getting Sytax error at

sheet.workbooks.open "C:\Documents and Settings\"&sapid&"\Desktop\mysheet.xls" ,true,false


Here is my code

Dim sheet
Dim sapid
sapid = InputBox("Enter your SAP ID :")
Set sheet = CreateObject("excel.application")
sheet.Visible = True
'sheet.workbooks.open localpath ,true,false

sheet.workbooks.open "C:\Documents and Settings\"&sapid&"\Desktop\mysheet.xls" ,true,false

Can any one help me in this.

Thanks in Advance,
Lakshmi...
 
I tried your code and it worked, well I did insert a couple spaces around the ampersands "&"...
sheet.Workbooks.Open "C:\Documents and Settings\" & sapid & "\Desktop\mysheet.xls", True, False

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top