I have an excel workbook that uses VBA. This VBA works fine except when it is executed on a clients laptop configured with Japanese language settings. I know in VB.NET that I would need to flip the Culture to EN-US and then flip it back when I'm done with the VBA but I can't for the life of me figure out how to get this solution to work in VBA. Is this possible? How so?
-Thanks
I don't think you can do this using just VBA: all the Application.Interrnational settings are read-only.
Usually the international problem is the other way round - VBA works in US-English.
What lines of code are giving you the problem in Japanese language settings?
Related
In the red range, the font is different from the system font. The system font is Microsoft YaHei UI, but these parts of the font is SimSun.
Is there a way to change these parts of the font?
Or is there a way to beautify the VBA editor? VBA editor is not pretty.
Check out [Tools] -> [Options] -> [Editor Format] - in there you can set the fonts used for various elements of the VBE.
I have an alternative solution.
VBA editor is ugly and doesn't have good intellisense. In addition, VBA is not fast.
These are reasons to prompt me to use Python+xlwings.
When I can use Python, beautiful editor UI and good intellisense I can get easily.
The most important, Excel operations will be faster.(numpy, pandas, etc can be used)
I am using xlwings to make Python operating Excel.
From the pictures, do the same operation to Excel, Python+xlwings only need 4s, but VBA needs 31s.
So if someone can use a little Python, I recommend using Python+xlwings to operate excel.
The VBA editor UI is based on Windows system fonts. You need to edit the windows registry keys to make the required changes, see How to change the default font in Windows® 8.1
This is going to sound absurdly stupid but here we go.
Over the course of my job this summer, I have developed several tools using VBA for the company. I am going back to school and in order to get credit for the job (and waive an internship requirement) I need to show what I've done.
In an appendix, my teacher would like to see the raw coding from my macros.
Now I know that I can print the script out directly from VBA but I am not able to format that the way that I would like before printing.
In addition, I would like to have the printout maintain the formatting from VBA (so tabbed lines and colored text) which I noticed printing it does not do.
Does anyone have any suggestions on what I could use to print out my scripts?
Thanks,
That guy who is hopelessly lost.
If you copy and paste the code into Notepad++, and save it as VB code, you can set the print setting (under Settings, Preferences, Print) to WYSIWYG.
Then, when you print it out, it will give you the indentation and colour coding.
I'm trying to use Excel to create AutoCAD drawings. I have a list of product numbers and I'd like to use VBA so that upon hitting a button it will find a block or a drawing file of every product on the list and paste them into an AutoCAD drawing (to a specific point would be a bonus).
So far I've found code that will read from two columns in Excel and will plot a polyline in ACAD using those columns as coordinates. It's very simple but not exactly what I want. Does anyone have suggestions or example code that does something similar? I've found some online using the "ThisDrawing." object but Excel isn't recognizing that so I've reached a stand still. I have all day tomorrow to work on it, so I'll be doing a lot more searching, but any help is definitely appreciated. Thank you
Autodesk provide free downloads on their website so that you can add the VBA IDE into AutoCAD.
Then, inside the AutoCAD IDE you start a new VBA project.
Add a reference to your Excel library so that you can read the Excel spreadsheet.
You need to look up on:
ThisDrawing.ModelSpace.InsertBlock
In the AutoCAD VBA manual. It tells you what various parameters. But they are straightforward - origin, scale, rotation, path to block.
When you call the InsertBlock routine it will create a AcadBlockReference object. You can do any further customization on that object.
What is the actual encoding used in Access' VBA editor? I have been searching for a concrete answer for quite a while but with no luck.
I thought it was UTF-8 but I'm not very certain.
My main issue is that when writing a query in VBA I sometimes need to test it in Access' query editor. When copy-pasting however, I lose my native characters (greek in my case) as they turn to gibberish.
I have tried pasting in a text editor and saving it as different encodings but I can never recover the original characters.
Thanks in advance.
Edit
Let me explain this a bit further:
As you can see I can write my greek characters in the VBA editor normally:
However, copying the first line in Access' query editor, I get the following:
Same goes for a simple text editor:
So I am inclined to think that the problem lies inside the clipboard, due to the encoding used for the greek characters. I guess they are not Unicode, as I indeed have to make the change in the System Locale for non-unicode characters. So how are these characters saved/copied? In what encoding?
Answer
Actually this problem was solved by switching the keyboard input language to greek (EL), when copying the actual test string.
I am still not sure however, as to why that happens. If anyone can provide some insight into this, I would love to hear it.
Thanks again
The VBA editor does not support Unicode characters, either for input or display. Instead, it uses the older Windows technology called "code pages" to provide support for non-ASCII characters.
So, the character encoding in the VBA editor corresponds to the code page that is used by the Windows system locale as specified in the "Regional and Language Options" control panel. For example, with my system locale set to "Greek (Greece)"
I can enter Greek characters into my VBA code
However, if I switch my Windows system locale back to "English (United States)"
and re-open my VBA project, the Greek characters have changed to the corresponding characters in the new code page
If "Control Panel" -> "Regional and Language Options" -> "System Locale" is set correctly but you still suffer from this problem some times then note that while you're copying your keyboard layout must be switched to the non-English language.
This is applicable to all non-unicode-aware applications not only VBA.
Credit goes to #parakmiakos
details in this: http://www.pcreview.co.uk/forums/use-greek-characters-visual-basic-editor-t2097705.html
Looks like making sure your OS is set properly, and font choice inside the VBA editor.
I had a similar problem with Cyrillic characters. Part of the problem is solved when set the System locale correctly.
However, The VBA editor still does not recognize cyrillic characters when it has to interpret them from inside itself.
For example it can not display characters from the command:
Msgbox "Здравей"
but if the sheet name is in cyrillic characters it does it well:
Msgbox Activesheet.Name
Finally, it turned out that these kind of problems were solved when I changed to 32 bits version of MS Office.
I think the title is fully descriptive now. Anyway, I need to generate a word document from my delphi application. It needs to choose from one of four different equations (with some specific parameters for each document). So far I have manage to create the whole document programmatically except the equation.
Is it possible to create equations programmatically? if so, where is de API documentation from MS? if not, which solution can be used?
Going the VBA route that Brian suggested will only give you the code to open Equation Editor; it won't give you the code for actually creating the equation.
Perhaps the MathType SDK will be of use to you. It's a free download.
Record a macro in a blank document of yourself adding an equation and then save the macro. Opening the macro up in the VBA editor will give you the exact VBA code required to programatically add an equation. If you're using Word's COM API, most of the methods in VBA should have COM counterparts. This technique can be used to discover how to programmatically do anything in Word that you can do in the GUI.