macro cannot open .xlsx file help!

mightyujin

New Member
Joined
Jun 15, 2011
Messages
12
Hi, I have excel 2003 and i use macro to copy data from a file that ends in .xlsx. the data file is coming from a department other than mine and i used macro to automatically copy the data from the .xlsx file to my excel file. However i cannot open .xlsx file using macro, and am wondering if I need to use some special code to do; i.e.,
Workbooks.Open Filename:=MRfile, UpdateLinks:=0, WriteResPassword:="4701", converter:=true?

I never used converter before and please let me know how to approach this to automatically open .xlsx file. Thank you for your help ;)
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
My whole code goes as below:

SIMSpath = "\\23.15.16.13\dat\WBGRPS\Market\NTVAST"
MRpath = "\\23.15.16.13\dat\WBGRPS\Market\Bond\Trust Bond\Bond(new)\Trust"
MRSheet = "1. BondStatus"

Range("H3").Select
Selection.End(xlDown).Select
EnterCell = Selection.Row + 1
DateCell = "H" & EnterCell: SIMSCell = "I" & EnterCell: MRCell = "J" & EnterCell

Numdays = Range("C7").Value
valuecell1 = "B" & 301: valuecell2 = "E" & 301

If Numdays = 1 Then

Set wf = Range("C5")
date1 = Application.WorksheetFunction.Text(wf, "ddmmyyyy")
date2 = Application.WorksheetFunction.Text(wf, "yyyy-mm-dd")
date3 = Application.WorksheetFunction.Text(wf, "mmdd")
SIMSfile = SIMSpath & "\" & date3 & "\SCFB\sims_trust_bond_" & date1 & ".csv"
MRfile = MRpath & "\" & "Market(" & date2 & ").xlsx"

Workbooks.Open Filename:=SIMSfile, UpdateLinks:=0, WriteResPassword:="1111", Password:="1111"
Range(valuecell1).FormulaR1C1 = "=SUM(R[-300]C:R[-2]C)"
SIMSsum = Range(valuecell1).Value
ActiveWorkbook.Close False

Workbooks.Open Filename:=MRfile, UpdateLinks:=0, WriteResPassword:="1111"
Sheets(MRSheet).Select
Range(valuecell2).FormulaR1C1 = "=SUM(R[-300]C:R[-2]C)"
MRsum = Range(valuecell2).Value
ActiveWorkbook.Close False

Range(DateCell) = Range("C5")
Range(SIMSCell) = SIMSsum
Range(MRCell) = MRsum


Red line is where i get code error. I get run time error '1004', Market(2011-06-15).xlsx: file format is not valid :mad:
 
Upvote 0
May be without "x"?
Code:
MRfile = MRpath & "\" & "Market(" & date2 & ").xls"
 
Upvote 0

Forum statistics

Threads
1,216,518
Messages
6,131,121
Members
449,624
Latest member
MandlaMan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top