2

I am running into a problem and can use some advice. I am linking to an excel spreadsheet and then i am trying to convert that link into a table.

my very basic function is as follows

dim mypath as string

docmd.transferspreadsheet aclink, acspreadsheettypeexcel112xml, "importeddata", mypath, true
runcommand acCmdConvertLinkedTableToLocal

this gives me a runtime error 2046 The command or action 'ComvertLinkedTableToLocal' isn't available now.

So, the reason for doing the link and then the conversion is when done manually, it will get rid of all the conversion errors that a normal import will do and then I have my basic VBA scripts which seem to run far quicker in Access than Excel.

Again, any help is duly duly appreciated

Groundhog.

2 Answers 2

4

I believe you need to have a specific linked table selected in order to run the acCmdConvertLinkedTableToLocal command. Try something like this after linking:

DoCmd.SelectObject acTable, "importeddata", True
DoCmd.RunCommand acCmdConvertLinkedTableToLocal

Alternatively, have you tried creating an empty table that matches the spreadsheet structure (i.e. using text fields instead of numeric fields) so that you don't get the import errors when you import instead of link?

Sign up to request clarification or add additional context in comments.

1 Comment

Worked as described. Such a silly missed step on my end.
0

Thank you for sharing this code example. I had to make one addition to get this to work correctly for me. I was getting a runtime message that the command was not available before adding a DoEvents after the SelectObject and prior to acCmdConvertLinkedTableToLocal.

1 Comment

Useful one. Even chatgpt/Bard failed to solve.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.