A2K Error 3011 on TransferSpreadsheet method - excel

I'm jut trying to import a spreadsheet into a table in Access 2000.
The spreadsheet is called cc-ledgcodebalances.xls with no field names.
My code is
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel3, "tmptmp", VFileName, 0
This seemed to work once but since then I now get this;
The Microsoft Jet database engine could not find the object
''cc-ledgcodebalances$''. Make sure the object exists and that you
spell its name and the path name correctly. 3011
Google searches aren't really turning up much that is useful. I'm trying to
import the whole thing and I don't think this is to do with named ranges.
Bit stumped by this, any help?

I answered this elsewhere that you asked it:
The error you're getting often occurs when the saved import spec is out of synch with either the source data or the target table. Try starting the import with the wizard, then load the saved import spec and it will likely throw an error or reveal what's no longer accurate.

I just had a similar problem under 2007 using direct range references instead of named ranges. It seems that dollar signs in the range reference can cause this error. Using Replace() on "$" and replacing with "" solved this issue in my case.

Related

Name conflict error pops when creating reference at runtime, but not at design time

I'm having this staggering problem in creating a reference at runtime.
In short: I have an addin referenced in another addins, all created by myself and all working fine (except for some annoying popup which appears on loading Excel). As a workaround to this annoyance, I removed the existing reference to create it later, at runtime. But when I try creating the reference, it returns an "Name conflicts with existing module, project, or object library" error popup, and the reference is not created--which makes no sense, because if I create the reference at design time it works perfectly. There is no module or project with repeated name.
Now explaining a little further.
I have four kinda-complex Excel applications I'd had developed for my job. Each one is a VBA project, distributed as Excel Addins (.xlam).
Additionally, I have a fifth project with functions common to the other four. This fifth project is referenced in the other ones (via Tools -> References). So now, all I have to do is to call them as any API outside referenced function (commonProject.Function (arg1, arg2, arg3 etc)).
Unfortunately, I had some problems with a popup message (here) and the workaround seems to be referencing the fifth project in the other ones at runtime.
In order to do this, I uninstalled three of the other four Addins, remaining only one, and used the following code in its Workbook_Open event:
Private Sub Workbook_Open()
Dim strNamePath As String
Dim bolAddinIsRefered as Boolean
Dim oRef As Variant
strNamePath = "c:\etc\etc\etc\Filename.xlam"
For Each oRef In ThisWorkbook.VBProject.References
If oRef.FullPath = strNamePath Then bolAddinIsRefered = True
Next oRef
If bolAddinIsRefered = False Then ThisWorkbook.VBProject.References.AddFromFile strNamePath
End Sub
The problem is, when I used to create the reference at design time by hand, it worked mostly fine (except for the annoying popup I'm now trying to circumvent). But when I try creating the Reference at runtime, it returns an "Name conflicts with existing module, project, or object library" error popup, and the reference is not created.
I have verified the module and worksheet names and there is no duplicated one.
Does anyone have any idea how to prevent this error?
it seems after one and a half day struggling with a problem, when you ask the question on StackOverflow the solution just pops in your mind.
I'd already tried to change both projects names, even internal functions or subs resembling the same name. But I had not looked upon the FILE NAME!
As my solution is called Sisyphus, the filenames of all addins started with "Sisyphus"--"Sisyphus Common Functions.xlam", "Sisyphus DocMerge.xlam" etc.
The problem was VBA was comparing the first word in filename. I removed spaces and it worked well. Now my filenames are "SisyphusCommonFunctions.xlam", "SisyphusDocMerge.xlam" etc. and the referencing in runtime works all right.
Thank you for your time, I'll let this Question and Answer here, because it can be usefull to someone.

MS Office last updates causing some strange behavior in handling VBA code

Our admins ran some MS Office 2016 updates (Build 11929.20838) and all of a sudden I noticed a few unexpected errors in one of my previously written Excel VBA macros. For example below error is popping up against any variable which I have not defined explicitly. It was not the case before and unless I had mentioned Option Explicit, I had never experienced anything like this.
Compile error:
Can't find project or library
I am also getting the same error against the following 2 statements of my code, whereas it used to run smoothly before the last Microsoft Office 2016 update.
' Against the following two declarations, the compiler is highlighting
' Date in parenthesis and quoting same error "Can't find project or library"
xMonth = VBA.DateTime.Month(Date)
xYear = VBA.DateTime.Year(Date)
' And showing same error as above against defining an Array variable like below
srchString = Array("invoice_number", "invoice_date", "Category_wise_code", "Bill To Customer", "consignees_address_long")
'And even here, it is giving the same error:
[A1].Font.Bold = True
Does anyone have any idea about these errors and how to resolve this issue? All of this quite unexpected. Let me tell you this macro has been in my use for over 4 years and I never ran into issues like these.
You will find something fishy here:
https://www.google.com/search?rlz=1C1CHZL_enGB838GB838&ei=EOInX-ibPMeusAXFw7z4Cg&q=%22ms+office+2016%22+%22july+updates%22+%22VBA%22&oq=%22ms+office+2016%22+%22july+updates%22+%22VBA%22&gs_lcp=CgZwc3ktYWIQAzoECAAQRzoICCEQFhAdEB46BQghEKABUOTJCljq_gtgg4UMaABwAXgAgAHzAogByiiSAQYyLTIuMTSYAQCgAQGqAQdnd3Mtd2l6wAEB&sclient=psy-ab&ved=0ahUKEwjo4_6J5f7qAhVHF6wKHcUhD68Q4dUDCAw&uact=5
Although not all links are opening, but Google window is briefly showing that some people are also facing macro crash situation.
Thanks for your time reading my post.

VBA Range.Cells unknown method or data member

Is anyone aware of any differences in versions of .NET/VBA/Excel etc that would cause a reference to Range.Cells to compile for most computers but not a client's new Mac ("with the error unknown data member")?
The code is:
Dim validationArr As Range
Set validationArr = Worksheets("sheet1").Range("B3:T3") 'Grab row dedicated to validation
For i = 1 To validationArr.Cells.Count
It thinks validationArr.Cells is unknown.
I'm just confused as to why it would compile and work on most computers including the client's old Mac but not on their new Mac.
I intend to replace it with validationArr.Rows(1).Cells.Count and see if it works but have yet to confirm.
Okay so for some reason the replacing it with validationRng.Count worked (I renamed the variable).
I faced similar unexplained compilation errors later on and exporting the module, deleting the module, and re-importing it fixed all compilation problems.
Bizarre.

Copy ManyToMany Value

I am currently trying to copy a many-to-many-field from one model to another but running into a bit of trouble. I have been able to create the model fine with a many-to-many-field with a ModelMultipleChoiceField, and the model saves the way I want it to. When I try to copy it to another model, I don't get an error, but nothing happens. Here is the code that I have tried:
author = Author.objects.create(author=self.author)
author = Author.objects.all()[0]
book = entry.approvers.all()
author.pk = None
author.readers.add(*self.readers.all())
I researched this all am and see that M2M models can be tricky. I've tried several variations of the code above and nothing works. I worked my way through several must be an instance errors this am, and that's how I discovered the author = Author.objects.all()[0] command. I no longer get an error but my many-to-many values are not being copied over to another model either. Thanks for any help.
I found this reference on SO and it seems to be what would help me but I tried it and it doesn't work. I am using generic class based views which is probably what is causing me a bit of additional grief.
Class Based Views (CBV), CreateView and request.user with a many-to-many relation
From the example, I used this template for my code but to no avail.
I get needs to have a value for field "id" before this many-to-many relationship can be used.
I just found this reference, Django. Create object ManyToManyField error
It works, and I can then use the following command to post one of the M2M values, but how can I do this without hard coding the pk?
book.reader.add('1')
The above works, but when I try something like
book.reader.add(*self.readers.all())
I've researched this further and this...
author = Author.objects.create(author=self.author)
Plus this alone works...
book.reader.add('1')
Just need to figure out how to replace '1' with a variable name.
After more investigation this may be related to the following issue?
Django: IntegrityError during Many To Many add()
It would seem maybe there is some kind of bug with the bulk_create? The individual add with a hardcoded number works just fine. When I try with the (*self.readers.all()) I don't receive an error message but the manytomany reference is not copied over to the over table. I've seen several articles that say that the commands I'm using work just fine, but perhaps it's for something other than PostgreSQL.
Thanks for any thoughts.
As a newbie, I was doing this work in SAVE. Once I moved it to post_save, the following format worked as expected...
#receiver(post_save, sender='Test.Book')
def post_save(sender,instance, **kwargs):
author = book.objects.create(subject=instance.book)
author.approvers.add(*instance.approvers.all())
As a newbie, I was doing this work by overriding SAVE in my model instead of doing this work in a post_save signal. Changing my approach fixed my issue. The code associated with my correct approach is..
#receiver(post_save,sender='Test.Book')
def post_save(sender,instance,**kwargs):
author = book.objects.create(subject=instance.book)
author.approvers.add(*instance.approvers.all())

Problems came up in the following areas during load: Table

I have generated an excel file from xml. But i can not open it with Excel. Excel gives the following error opening it:
Problems came up in the following areas during load:
Table
Then it shows a message that the log file corresponding the error can be found at : C:/Documents and Setting/myUserName/Local Settings/Temporary Internet Files/Content.MSO/xxxxx.log
But i can not find Content.MSO folder in my windows. I checked folder settings and made all folders visible but i still can not access this folder. So that i can not analise the log file.
how could i find the generated log file?
I found the problem without analising the log file. i stil can not access the log file in temporary internet files. But i realised that i put a string(non-number) characters on a number-styled cell in Excel xml. So if you having the similar issues about your Excel file generated from xml, then have a look at if your cell values are appopriate with your cell data type.
If you type or paste the path of the log file into Explorer or your text editor of choice, you may find that the folder does exist, despite being invisible.
In my case it was a <Row> with an incorrect ss:Index
I was using a template and the last row had a fixed Index=100. If the number of rows I added exceeded 100, this last row had a wrong index and excel threw the error without any other message or log (MacOSX, Excel 15.25.1). I wish they printed more informative error messages, what a waste of our time.
Excel 2016. My error message was "Worksheet Settings". Path was pointing to non-existing file.
My cause of the problem was ExpandedRowCount not big enough for number of rows in Worksheet. If you add rows in XML directly (i.e. on a machine where Excel is not installed), make sure to increment number of rows in ExpandedRowCount.
yes.Even i too faced the same problem and problem was with the data type of cells ofexcel generated using xslt
In addition to checking the data being used vs "Type" assigned, make sure that the list of characters that need to be encoded for XML are indeed encoded.
I had a system that appeared to be working, but then some user data including & and < was throwing this error.
If you're not sure what's going on with your file, try http://www.xmlvalidation.com/ - that helped be spot the issue in a large file immediately.
I used this function to fix it, modified from this post:
function xmlsafe($s) {
return str_replace(array('&','>','<','"'), array('&','>','<','"'), $s);
}
and then run echo xmlsafe($myvalue) where you were just echoing $myvalue in your script.
This seems to be more appropriate for XML than htmlentities() or other options built into PHP.
I had the same issue, and the answer was - type of Cell was Number and some values doesn't converts to this type on my backend.
I had the SAME problem,
and its because de file is TOO BIG.
I try an extract from SAP, more little than the one with that make the error) and save it in XML file. and it WORK, no more error.
so maybe if you can save in 2 Excel files XML instead of 1 it will be good ;)
ALicia

Resources