I am using act_as_xlsx for generating excel sheets. Everything is fine, except when I try to change the column headers with en.yml, I get this error
Worksheet.name. must be [String]
Any idea why this is happening?
Related
=QUERY('SHIPMENT LIST'!3:4341,"SELECT A WHERE Q='"&E1&"'AND N='"&F1&"'")
I wrote this on a workbook and it works fine but when i try the same thing in different spreadsheet with importrange i got an error
Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: A.
Is my syntax wrong or something?
=QUERY(IMPORTRANGE(B1,"SHIPMENT LIST!3:4341"),"SELECT A WHERE Q='"&C2&"'AND N='"&C4&"'")
I've created a C# dll using the web service wsdl.exe. Based on that I have create both a C# and VB.Net application, and they both retrieve the data I expect and give me the result.
The VBA code that calls the same external dll fails. The dll returns an object that has a property 'DataArea' that is an array of objects.
Dim response As CustomerPrice.SimulatePriceResponseType
Set response = New CustomerPrice.SimulatePriceResponseType
Set response = CustPriceService.SimulatePrice(st)
Dim bob As String
bob = response.DataArea(0).bookPrice_Value
In C# and VB.Net the last line gives the value required.
In VBA the last line indicates a 'Wrong Number of arguments or invalid property assignment'
In 'Immediate mode debugging'
Print response gives SimulatePriceResponseType as expected.
Print response.DataArea gives Type Mismatch (error 13)
Print response.DataArea(0) gives wrong number of arguments (error 450)
Any ideas what is happening and what I can do to fix it?
It seems that it has something to do with the array, or with how VBA is interpreting it, although I am not sure exactly what.
I found the dll source code and added a property that returned only the first element of the array as an PriceData object, not an PriceData[] array.
Works as it should
I'm trying to save an activeworkbook but when I use the following code, I keep getting the error "compile error: expected function or variable" with the word "format" highlighted.
It boggles my mind because I used the exact same function and format in another macro and it saved the file perfectly. I also made sure they had the same types of variables defined already...
Here's the one line code
ActiveWorkbook.SaveAs Filename:=SavedPath & format(Date, "mmddyyyy") & " 4512 GLUpload.xlsm"
The variable savedpath is fine because when I run this line without the format part, it saves the file, but not sure why this screw it up. Also noticed in my other code, format is capitalized but it's not here.
The compiler error you are getting indicates that VBA is expecting an assignable value (either a literal, a variable, or the return value of a function). This means that one of the identifiers in the statement to the right of the equals sign doesn't fall into those categories. So, either SavedPath is defined somewhere as Sub SavedPath(), or there is a Sub Format(arg1, arg2) defined somewhere (if it had a different number of arguments you would get a "Wrong number of arguments or invalid property assignment" error). The second clue (in the comments) is that changing format to the strongly typed Format$ gave a "Type-declaration character does not match declared data type" error. This points to the compiler not treating the symbol format as a function call (Format$() is the strongly typed version of Format()). The solution is to track down the errant use of the VBA function name and re-name it.
A perfect example of why avoiding VBA keywords and function names is good practice.
I am trying to run an update query but it is giving me "Data type mismatch in criteria expression". It was working just fine before but now, all of sudden it started giving me this error. I tried doing research and also checked in stack overflow but could not find the solution. I only have one criteria expression in my query.
UPDATE dbo_tblGoods INNER JOIN qryValidate
ON dbo_tblGoods.MaterialID = qryValidate.MaterialID
SET dbo_tblGoods.BarcodeType = [qryValidate]![BarCodeType],
dbo_tblGoods.BarCode = [qryValidate]![BarCode]
WHERE (((Right$([NewBarCode],4))="GOOD"));
Also, qryValidate is:
SELECT Parts.MaterialID, Validate_UPC([Parts]![Barcode],[Parts]![BarcodeType]) AS NewBarCode,
Parts.BarCodeType, Parts.BarCode
FROM dbo_tblgoods INNER JOIN Parts
ON dbo_tblgoods.MaterialID = Parts.MaterialID;
Whenever I got the error "Data type mismatch, I always check those fields I have with expression "=,>.." or Function. Most likely, the cause of the error is a Null field.
Try to check your function Validate_UPC([Parts]![Barcode],[Parts]![BarcodeType]) and change it to Validate_UPC(nz([Parts]![Barcode]),nz([Parts]![BarcodeType])) for Null fields.
If it doesn't work, then go check if the parameters in Validate_UPC matches the data type you supplied in your query. e.g. If you declared Barcode as Integer, a string field is not valid. Try to declare the Barcode or BarcodeType as Variant and properly handle them in VBA.
Lastly, you are trying to inner join fields on two or more tables that are not of the same data field types. I often make this mistake when I create new temporary tables out of data imports(e.g. excel imports)
I have an excel sheet with 15k data and I realized there were 2 cells which were empty. Therefore, it was giving me this error. Thank you all for trying to help me out.
I am using closedXML to take a datatable and place this into an Excel file.
The code I am working with works, with 99% of the files I put through the application, but I get an error with a file every now and then. (no this is not a debugging issue)
The problem must originate from the data, however I am at a loss on how to resolve this.
The code I'm using is
Public Sub WriteToExcel(dt As DataTable, filePath As String)
Dim workbook = New XLWorkbook()
Dim worksheet = workbook.Worksheets.Add(dt, "Call Validate Export")
Try
workbook.SaveAs(filePath)
Process.Start(filePath)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
When saving the file I get the error
'', hexadecimal value 0x1A, is an invalid character.
between the '' there is a little arrow pointing to the right.
When reading the file in to the datatable it reads in fine, looking at the file I see no hex characters.
The file being read in is a ^ delimited csv file.
So, my question is how to I check and repair\replace the bad characters in the output that will allow me to save 100% of the time.
From the XML specification ( https://www.w3.org/TR/xml/#charsets )
Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] /* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. */
Which implies that character #x1A is an invalid character. You should manually remove it.
#Simon,
It looks like whatever you are trying to export to Excel, it contains some invalid characters (Arrow pointing to right side).
I was receiving the similar error and upon detailed look, I come to know that I am exporting DataTable into Excel and one of the cell value of DataTable was looking like:
Please Note -> Some comment (Here, -> is actually a single character : Arrow pointing to right side)
I have removed those characters and it is working fine now.
Hope this helps.
https://github.com/ClosedXML/ClosedXML/pull/66 is a pull request which could solve your issue. Please try it.