VBA Range function suddenly accepts only localized arguments (pt-BR) - vba

I'm using the brazilian-portuguese version of Excel on a Windows 7 also pt-BR.
I have a spreadsheet that I use for months in the same machine, same excel version, same etc. and a vba code that worked until today. As far as I know I have changed nothing.
The code was: Range("tabReport[[#All],[Valor]]")
Today when i ran the macro it gave me an error: Run-time error '1004': Method 'Range' of object '_Global' failed
After several trial and error I corrected to: Range("tabReport[[#Tudo];[Valor]]")
Notes:
1) "Tudo" is "All" translated to pt-BR.
2) Comma "," became semicolon ";", the equivalent in pt-BR local syntax.
What bugs me is this change from nowhere, that could affect other workbooks.
Also I prefer mantain my macro in USA English (Global) syntax mode, so it's easier to google and mantain.
Anyone have a clue about how can I control this behavior?

Related

Document Export failing in ms-project vba

I have code that prints specific views to pdf using a specific fromDate and ToDate. My code started failing when I updated to ms Project 2016. Any ideas?
I've even tried removing the FromDate and ToDate and still get the error. When I add a watch to DocumentExport the Saveas dialog is displayed with the wrong filename, meaning the filename I am passing is not correct.
ViewApplyEx Name:="Gantt Employee", ApplyTo:=0 'view name
DocumentExport FileName:="C:\Schedules\test.pdf",FromDate:=printDate, ToDate:=printDateEnd
Run-time error '1004': Application-defined or object-defined error
Realized I didn't have the latest office 365 build due to being on the semi-annual update channel. I switched to the monthly channel updates and the problem was fixed.

VBA (Word) - can i see if application is already open

I've been having experiencing an issue with Word VBA where, if the Application is already open, it would just crash and doesn't do any further steps. I've been surfing the Net trying to figure this out, but no luck. The error appears at the o.Workbooks.Open line:
Dim o as Excel.Application
o.Workbooks.Open (ActiveDocument.Path + "\Data.xlsm")
Error message is
c:\fol\data.xlsm is already open or doesn't exist
It basically saves the data that was entered in Word text boxes. Note: All code afterwards works fine, this is the line where it breaks. I've tried using On Error that it would just stop, but it doesn't seem to work :/
Any ideas?

VBA Error 4605 This method or property is not available because the document is in modal state

Environment: Word 2016 for Mac.
The following code (which works fine in Word 2007 and 2010 for PC and Word 2011 for Mac) throws run time error 4605 at the point of the paste:
Set oSubRange = wdDoc.Sections(i).Range ' we are in a loop...
oSubRange.End = oSubRange.End - 1
oSubRange.Copy
Set wdSubDoc = Documents.Add
wdSubDoc.Activate
Set oRange = wdSubDoc.Content
oRange.Collapse (wdCollapseEnd)
oRange.PasteAndFormat (wdFormatOriginalFormatting)
My thoughts were that maybe this was a sandboxing problem, but I don't think so because I have had no issues with saving files, and this is not at the point of save anyhow. Other thoughts were that the clipboard was not copying, that perhaps there was a timing issue. I tried inserting a DoEvents() after the copy as I have seen this suggested in different error 4605 scenarios (different error though). Also tried using ActiveDocument.Range.PasteAndFormant(wdFormatOriginalFormatting) which was suggested in another forum by a MS MVP (again, different error 4605). None of these solutions worked.
So, I am stuck.

VBA Excel 2010 FormatConditions failing Application Defined or Object Defined Error

I have a VBA code that I used to use in an Excel 2016 (64-bit), and it works fine.
But when I tried to use in a Excel 2010 (32-bit) version, I've got an error "Runtime Error (1004) Application Defined or Object Defined Error" in the following line:
CndFrmtType = Sh.Cells.FormatConditions(CndFrmtItem).Type
I've already tried to re-build the file in a 2010 Excel (from the ground, to avoid reference's issues), but it still not working.
I really tried to google it, but didn't find anything about an eventual incompatibility in the FormatConditions object.
The returned FormatConditions object is as follows:
Can anyone help me on this?
be sure you have:
set Sh to a valid Worksheet object
initialized CndFrmtItem to a valid name or index number to reference a format condition of that worksheet
declared CndFrmtType as of Long type
and it'll work

Excel / VBAfrom x language to english version

I'm trying to run a VBA / Excel program on 2 different pc's.
One is with the dutch version of Excel (VB 7) and one with the english one (VB 6.5).
When i try to run a function, i get the error:
Run-time error '32809':
Application-defined or object-defined error
When i strip down all code to just displaying a msgbox, the error still persists.
When i create a new tab, that tab can execute code.
I suppose this has something to do with wrong translation?
Any help on this?
Thanks!
Problem solved:
Store you excel file as .xls and not as .xlsm
Thanks team :)