VBA StrConv with vbNarrow throw Run-time eror '5'

993 views Asked by At

I have an excel file which work well with Excel 2007, now my company upgrade all PC to Windows 10 Enterprise v1809 and Office 2016, then it got error runtime error 5.

Here is my code, the error throw from StrConv line,

Tried Google but no help, is there anyway may help me fix this problem?


Update 1:

I'm working with many Japanese documents so I've changed my system locale to Japanese (in Control Panel/Region/Administrative/System Locale)

Update 2:

I don't want to convert Kanji (Chinese characters in my source), I want to convert double-byte English characters (1F-2F) to single-byte English character (1F-2F)

Public Sub 階段問合せ書作成()

Dim Kaidan1 As Worksheet
Dim N_ws As Workbook
Dim WB As Workbook

    Set WB = ActiveWorkbook


    jigyousyo = Range("事業所")
    kaidan_name1 = StrConv(Range("階数①").Value, vbNarrow)
    kaidan_name2 = StrConv(Range("ŠK”‡A").Value, vbNarrow)

debug info

strconv runtime error 5

my system locale is Japanese

2

There are 2 answers

2
D T On

You have to change System Locale and Format in Region to Japanese

1
chucta On

The syntax of the function is

StrConv(string, conversion, [ LCID ])

Instead of

StrConv(Range("階数①").Value, vbNarrow)

You may use this instead.

StrConv(Range("階数①").Value, vbNarrow, 1041)

1041 is Locale ID of Japan. No matter what the system locale and Format in your PC is set to, it should work.