PDA

View Full Version : open file with vba



amitziti
08-22-2020, 02:41 PM
hello,
im trying to write a vba code to open other excel workbook that every month changing the name in the number of the month.
i want that excel will open the workbook automaticly and im getting error that it cant find the file.
this is the code that i wrote:

sub macro1

dim myname as string
myname = inputbox ("write the number of the month")
myfileorly = "orly" & myname

chdir "f:\excel"
workbooks.open filename:= _
"f:\excel\myfileorly.xlsx"

end sub

jolivanes
08-22-2020, 10:02 PM
Try

"f:\excel\" & myfileorly & ".xlsx"

amitziti
08-23-2020, 08:17 AM
it still cant find the file