在VBA中附加正斜杠(excel)

时间:2016-03-08 10:50:03

标签: excel vba excel-vba append

我正在尝试将正斜杠附加到某个文本文件的末尾但是当我附加正斜杠时,它显示为" /"而不是/

我向您提供了我的代码,如果您能帮助我解决问题,我感谢您。

Sub AddBackslash()
  'Set variable R as Range for reading a whole list of column
  Dim R As Range
  Dim BK As String

  'Below variable is to hold string
  Dim SourcePath As String, DestPath As String, FName As String
  Dim myFile As String, text As String, textline As String, posLat As Integer, posLong As Integer

  'set sheet2 as active sheet for retrieve data at column A of sheet 2
  Worksheets("Sheet2").Activate

    BK = "/"


  'Visit each used cell in column A
  For Each R In Range("B2", Range("B" & Rows.Count).End(xlUp))

    'MsgBox "Name:" & R

    myFile = R
    Open myFile For Append As #1
    Write #1, Chr(47)
    Close #1

  Next
  ChangeSheet ("Sheet1")
End Sub

当前输出样本:

  

这是一个例子。" /"

我希望输出如下:

  

这是一个例子./

1 个答案:

答案 0 :(得分:0)

您可以使用Print而不是Write 因为Print不包含双引号