简体   繁体   中英

Append forward slash in VBA (excel)

I am trying to append forward slash to end of some text file but when I append forward slash, it appears as "/" instead of a /

I provide you my code, I appreciate if you can help me to fix the problem.

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

sample of current output:

This is example."/"

I would like the output be like:

This is example./

您可以使用“打印”而不是“写”,因为“打印”将不包含双引号

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM