回答編集履歴

4

誤字の修正

2019/10/10 05:21

投稿

mattuwan
mattuwan

スコア2163

test CHANGED
@@ -32,7 +32,7 @@
32
32
 
33
33
  Set wb = ActiveWorkbook
34
34
 
35
- sFilePath = Replace(wb.Name, "xlsx", "csv")
35
+ sFileName = Replace(wb.Name, "xlsx", "csv")
36
36
 
37
37
 
38
38
 

3

誤字の修正

2019/10/10 05:21

投稿

mattuwan
mattuwan

スコア2163

test CHANGED
@@ -20,27 +20,35 @@
20
20
 
21
21
  手動で出来てるなら、
22
22
 
23
+ ```ExcelVBA
24
+
23
25
  Sub Macro1()
24
26
 
25
27
  Dim wb As Workbook
26
28
 
27
- Dim sFilePath As String
29
+ Dim sFileName As String
28
30
 
29
-
31
+
30
32
 
31
33
  Set wb = ActiveWorkbook
32
34
 
33
- sFilePath = Replace(wb.Path, "xlsx", "csv")
35
+ sFilePath = Replace(wb.Name, "xlsx", "csv")
34
36
 
35
37
 
36
38
 
37
39
  Application.DisplayAlerts = False
38
40
 
39
- ActiveWorkbook.SaveAs Filename:=sFilePath, FileFormat:=xlCSVUTF8, CreateBackup:=False
41
+ ActiveWorkbook.SaveAs Filename:=wb.Path & "\" & sFileName, _
42
+
43
+ FileFormat:=xlCSVUTF8, CreateBackup:=False
40
44
 
41
45
  Application.DisplayAlerts = False
42
46
 
43
47
  End Sub
48
+
49
+ ```
50
+
51
+
44
52
 
45
53
 
46
54
 

2

追記

2019/10/10 05:19

投稿

mattuwan
mattuwan

スコア2163

test CHANGED
@@ -13,3 +13,43 @@
13
13
  http://acoustic-groove.hatenablog.com/entry/2017/11/11/003157
14
14
 
15
15
  https://tonari-it.com/excel-vba-utf8-write/
16
+
17
+
18
+
19
+ -----
20
+
21
+ 手動で出来てるなら、
22
+
23
+ Sub Macro1()
24
+
25
+ Dim wb As Workbook
26
+
27
+ Dim sFilePath As String
28
+
29
+
30
+
31
+ Set wb = ActiveWorkbook
32
+
33
+ sFilePath = Replace(wb.Path, "xlsx", "csv")
34
+
35
+
36
+
37
+ Application.DisplayAlerts = False
38
+
39
+ ActiveWorkbook.SaveAs Filename:=sFilePath, FileFormat:=xlCSVUTF8, CreateBackup:=False
40
+
41
+ Application.DisplayAlerts = False
42
+
43
+ End Sub
44
+
45
+
46
+
47
+ こんな感じでいいんではないかなぁ。。。
48
+
49
+ こちらは2010なので保存できませんが^^;;
50
+
51
+
52
+
53
+ 参考HP>>
54
+
55
+ [Excel 2016でUTF-8のCSVファイルがサポートされるようになりました。](https://www.ka-net.org/blog/?p=7764)

1

追記

2019/10/10 05:10

投稿

mattuwan
mattuwan

スコア2163

test CHANGED
@@ -5,3 +5,11 @@
5
5
  手動でやってみても、文字化けしますか?
6
6
 
7
7
  出来たテキストファイルを開くときはどんなアプリ使ってますか?
8
+
9
+
10
+
11
+ https://did2memo.net/2016/11/14/excel-csv-utf8/
12
+
13
+ http://acoustic-groove.hatenablog.com/entry/2017/11/11/003157
14
+
15
+ https://tonari-it.com/excel-vba-utf8-write/