Run-Time Error 438 - Object doesn't support this property or method

thapco4

New Member
Joined
Jan 24, 2020
Messages
4
Office Version
  1. 365
  2. 2016
  3. 2013
  4. 2010
Platform
  1. Windows
I set this up a while back and everything worked fine, but now it just dies on the very first line (red text). I created it by doing a macro and then putting it in the vba. Goal is to convert the data in the columns to text, before performing the query create, in order to prevent this type of error if I remember my thinking correctly.Here is the code...

Sub create_queries()

' Sheets("Sheet1").Select
' Range("A2:H2").Select
ActiveWorkbook.Queries.Add Name:="Table1", Formula:= _
"let" & Chr(13) & "" & Chr(10) & " Source = Excel.CurrentWorkbook(){[Name=""Table1""]}[Content]," & Chr(13) & "" & Chr(10) & " #""Changed Type"" = Table.TransformColumnTypes(Source,{{""SO No"", Int64.Type}, {""Date"", type date}, {""PO No (Customer)"", type text}, {""Ship By"", type date}, {""Status"", type text}, {""Customer ID"", type text}, {""Customer"", type text}, {""Amount"", Currency.Type}})" & Chr(13) & "" & Chr(10) & "in" & Chr(13) & "" & Chr(10) & " #""Changed Type"""

ActiveWorkbook.Connections.Add2 "Query - Table1", _
"Connection to the 'Table1' query in the workbook.", _
"OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=Table1;Extended Properties=" _
, """Table1""", 6, True, False
Sheets("Sheet2").Select
ActiveWorkbook.Queries.Add Name:="Table2", Formula:= _
"let" & Chr(13) & "" & Chr(10) & " Source = Excel.CurrentWorkbook(){[Name=""Table2""]}[Content]," & Chr(13) & "" & Chr(10) & " #""Changed Type"" = Table.TransformColumnTypes(Source,{{""SO/Proposal No."", Int64.Type}, {""Item ID"", type text}, {""Item Description"", type text}, {""Item Type"", type text}, {""Order Qty"", type number}, {""Qty on Order"", type number}, {""Amt on Order"", Currency.Type}, {""Qty on Hand" & _
""", Int64.Type}, {""Qty on PO's"", Int64.Type}, {""Qty Available"", Int64.Type}, {""Ready to Ship"", type text}})" & Chr(13) & "" & Chr(10) & "in" & Chr(13) & "" & Chr(10) & " #""Changed Type"""
ActiveWorkbook.Connections.Add2 "Query - Table2", _
"Connection to the 'Table2' query in the workbook.", _
"OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=Table2;Extended Properties=" _
, """Table2""", 6, True, False
Sheets("Sheet3").Select
ActiveWorkbook.Queries.Add Name:="Table3", Formula:= _
"let" & Chr(13) & "" & Chr(10) & " Source = Excel.CurrentWorkbook(){[Name=""Table3""]}[Content]," & Chr(13) & "" & Chr(10) & " #""Changed Type"" = Table.TransformColumnTypes(Source,{{""PO No"", type text}, {""PO Date"", type date}, {""Vendor ID"", Int64.Type}, {""Vendor Name"", type text}, {""PO State"", type text}, {""Item ID"", type text}, {""Line Description"", type text}, {""U/M ID"", type text}, {""Qty Ordered" & _
""", Int64.Type}, {""Qty Received"", Int64.Type}, {""Qty Remaining"", Int64.Type}})" & Chr(13) & "" & Chr(10) & "in" & Chr(13) & "" & Chr(10) & " #""Changed Type"""
ActiveWorkbook.Connections.Add2 "Query - Table3", _
"Connection to the 'Table3' query in the workbook.", _
"OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=Table3;Extended Properties=" _
, """Table3""", 6, True, False


End Sub

Here is a sample of the table it is working on...
SO NoDatePO No (Customer)Ship ByStatusCustomer IDCustomerAmount
4360301/8/209990672611/8/20OpenDDPCSFxxxxxxxxxxx5,477.94
4360761/23/201275591/23/20OpenDXACUIrrrrrrrrrrr1,045.09
4360751/23/201275581/23/20OpenDXACUIrrrrrrrrrrrrrrr119.23
4354245/14/19HJ23265pg-11-1905145/14/19OpenDXAUDAhhhhhhhhhhhhh79.80
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Where's the first = in the formula which should be in quotes. Anything that is meant to be text has to be in double quotes, so what exactly would is .Formula = "let" & supposed to do?

A properly formatted example

VBA Code:
.Formula =  "=IF([@ModTm],IFERROR(OFFSET([@Change],-1,,1,1)+1,[@Offset]+1),0)"

If you only need the outcome being placed in the sheet each time you run the script look at the X = Evaluate("Your Excel Formula") VBA solution. In that case = is not required ;O)
 
Upvote 0
It is multi-line code (ie carriage return). The "first =" is on the first red line "...,Formula =_". The "_" character tells the vba to continue on next line. Is that what you are asking?
 
Upvote 0
Yes, and still it would need at least the = sign after the first quote, so .Formula = "=let" & et cetera , at least it's how it works in my book. The other maybe is VBA could be interpreting "let" as needing ""Let"", double quotes i.e. text, but doubt that's the issue.

OT\ "let" is a serious throwback to the days of Basic on DOS 2.0 /OT. Not used it in decades.
 
Last edited by a moderator:
Upvote 0
Well, I checked that... it didn't help. I appreciate the help. I think the problem may be in the part about the TableTransform or the Queries.Add itself.
My VBA isn't that extensive.
 
Upvote 0
Actually, I just thought of this. I think Microsoft "upgraded" me from 2016 to 365 a few months back. That may be when it quit but I have no way of knowing. Anyone have experience with this as the possibility, especially if "let" has been deprecated?
 
Upvote 0
VBA development is on close to standstill. Saw something that suggests them pushing Office Script, which is really really a DOS throwback from what I saw.
 
Upvote 0

Forum statistics

Threads
1,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

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