Why does AscW() give a Compile Error in Excel 2010? - vba

I'm trying to do this in Excel VBA:
Cells(1, 2) = AscW(Cells(1, 1).Value)
It works fine in Excel 12 (2007) and 16 (2016) on one of my machines (Windows 7 laptop), but the machine (Windows thin client, not sure the version but looks a bit like Windows 7) that has Excel 14 (2010) gives "Compile error: Wrong number of arguments or invalid property assignment".
Any ideas? Is it the machine, a bug/feature in that version of Excel, or something else?
Update It seems to matter which machine the workbook was created on. They are both .xlsm files, but the one I created on the laptop works fine when I copy it onto the thin client. The workbook that I created on the thin client (actually, I received from someone else) has the problem. Both have the public sub in the worksheet's VBA code. Sadly I cannot transfer files in the other direction.

Related

"object not available on this machine" on another machine running the same version of excel

I have written some VBA code which works fine on my machine and sent it to someone for testing. When they attempt to run the code on their machine they get an error message stating: "Could not load some objects because they are not available on this machine."
Some research has revealed the likely issue is the fact that I am using a Date Picker object in a userform, which supposedly doesn't work on all versions of excel. However this person is running excel 2010 32 bit just like me, so I don't understand why it wouldn't work.
Is there anything I can do to ensure my code will run on any machine running excel 2010 32 bit? Or do I have to revert to using textboxes D:
thanks for your thoughts.

Office server automation failed while calling "CopyPicture" on some computers

We have wrote an application with C++/Qt which reads some data from multiple excel files and then generate a word report. We have used benefits of Office automation server to read/find and copy data from excel files and write them into a single word file.
The application works fine without any significant problem in my office computers. Yesterday I've decided to copy the app into my laptop which has same OS and office version. After running the app, it seems that somethings wrong my OS/Office. None of the data are copied into word file. After debugging I've figured out that the app actually can read/write office files but failed to call CopyPicture method of automation!!!
I wanted to copy the range as picture, so I have used "CopyPicture" method. but it seems that the vba fails to call copyPicture on my laptop.
I'll be very appreciated for any hints. Thank you
I've found the problem and it's with excel docs which are used to copy data from. In these files, there are some embeddedCharts. after removing these charts the code works fine!!!! (very odd). Anyway, I've tried to make excel file visible in order to see if the operation goes well or not. After running (with embeddedCharts) the code worked fine (more odd!!)
excel->dynamicCall("Visible", true );
I don't know the reason but with making excel file visible, the error with copyPicture is gone!

Secure VBA Excel Addin Code

I have an Excel addin, developed in VBA, deployed on the network.
The addin reads from an Oracle database, and pastes tables in a new worksheet, which will also contain a button (triangle shape) to refresh the table.
Everything works great, but I must protect code with password.
When i do, the following error appears on some machines:
Compile error in hidden module: Main.
This error commonly occurs when code is incompatible with the version, platform, or architecture of this application.
Although it compiles perfectly when unlocked.
On other machines it requires VBA password on close, even though i have nothing of the sort defined under close event.
I am hoping to secure my code, without running into above problems.
Any suggestions are appreciated.
I know of two situations in which this error occurs:
1: 32bit vs. 64bit issues (already mentioned in the comments). If you've developed a 32bit addin and try to deploy/use it within a 64bit Excel, then your quoted error message will appear.
2: Missing references.
I think the second option is more likely to be the cause of the problem, because usually all client PCs in a company will have the identical version of MS Office installed and this error occurs only on some machines.
So I suggest to check your references. In the VBA-Editor (Alt+F11) go to tools --> references and note down any ticked modules. Then compare this to a client where the error is occuring (go to client PC and repeat the procedure).
If the ticked modules don't match between development and client PC, this is most likely the cause of this issue. You might also encounter modules with a "MISSING" written in front of their name on the client PC. In this case, remove the tick from the missing module and try to execute your addin.
If it works flawlessly you should be good to go, if not you'll have to manually install the missing modules on the clients PC.
Hope this will help you.

Interop excel doesn't copy charts using vb.net on windows8

I'm building a program that makes excel based reports using xlsx files using the Microsoft.Office.Interop.Excel library and Visual Studio 2010.
I have a xlsx file with 2 charts, and some styles. Using...
Dim LibroExcel As Excel.Workbook
Dim HojaExcel() As Excel.Worksheet
LibroExcel.Worksheets(1).copy(After:=LibroExcel.Worksheets(i))
HojaExcel(i) = LibroExcel.Worksheets.Item(i + 1)
... I copy that sheet to another sheet until the for instruction I use ends.
The problem: In a system with Windows8 when I use this function, the charts are not copied from one sheet to the next one. But if I do the same on a Windows 7 system, it works. Both systems are using the same version of Excel.
I have been searching on the internet, and following the steps on the next post i have resolved my problem:
https://stackoverflow.com/a/13174856/4587472
Also i applied the next steps because the first time i didn't found Microsoft Excel Application:
On 64 bit system with 32 bit Office try this:
Start
Run
mmc -32
File
Add Remove Snap-in
Component Services
Add
OK
Console Root
Component Services
Computers
My Computer
DCOM Config
Microsoft Excel Application
Anyway, can someone explain what this steps really do? (This steps and the post steps)

'File Not Found: VBA6.dll' Error - Strange Behaviour

I am running Windows 8 with Office 2013 (64-Bit). I am trying to continue developments in VBA in Excel that I started with Office 2010 (32-Bit). I am aware of the necessary 64-Bit alterations however I am receiving confusing configuration errors.
Here is the problem:
If I create a new Excel file and VBA project; all my VBA code functions correctly. No problems.
If I open and use a macro from a file that was developed/used in Office 2010 previously, I receive a "File Not Found: VBA6.dll" error message.
Once I start receiving the message, I receive it on all VBA macro's; even the new ones that (not more than 30 seconds) previously worked fine.
If I then re-create a new Excel file and new VBA Project, that individual piece of new code works fine. No problems - until I run code in one of the 'error files'. The fault then spreads into my new developments.
It's as if Excel is getting its references confused but every time I check them (on good or bad files) they are always exactly the same.
Note:
None of my references are missing.
I don't have VBA6.dll on my system; I have VBA7 and the 'Visual Basic for Application' reference refers too 'C:\Windows\SysWOW64\msvbvm60.dll'
There are two other 'Visual basic for Application' references on the list but it wont let me change them
It works on new files without VBA6.dll so I assume it isn't required?
I have checked for and installed all the latest Windows updates.
What should I do to troubleshoot this problem?
If you think I need VBA6.dll, is that because the referenced libraries use it?
If so then why are they not using VBA7?
And why does it work correctly before opening an old VBA6 file? Does Excel suddenly decide all files must use VBA6 just because one file did previously?
Anything to cure me of my confusion is much appreciated,
Best regards
EDIT: I almost forgot to mention;
When I try to debug the error after receiving it, Excel crashes (every time).
I also sent a 'bad file' to a colleague who [with the same system configuration] hasn't yet received this problem - and they also received the error. Suggesting it is something wrong with the files?
EDIT 2:
The problem is not yet resolved. I hope the downvote will not hinder my chances of an answer.
I have also tried re-registering libraries but nothing has changed.
If I open a 'bad file' I can add new Macros and they work fine; but the second I run an existing Macro and receive the error, the new Macros do not work either.
The error was caused during Office 2013 (64-bit) installation. The VBA7 DLL was not registered correctly so I had to open regedit and manually input the correct filepath in both
HKEY_CLASSES_ROOT\TypeLib{000204EF-0000-0000-C000-000000000046}\
6.0\9\win32
4.2\9\win32
Replacing the 'C:\Windows\SysWOW64\msvbvm60.dll' data value (mentioned in the question) for Visual Basic for Applications to the VBA7 DLL filepath. Which on my system is:
C:\Program Files\Common Files\Microsoft Shared\VBA\VBA7.1\VBE7.dll
All files now work; I hope this solves the problem for anyone else in the future.