VBA adding extra quotation marks

AnthonyMinnaar

New Member
Joined
Aug 25, 2020
Messages
28
Office Version
  1. 2013
Platform
  1. Windows
Hi folks,

When I run the VBA code as seen below, it adds extra quotation marks in the output. It just needs to be "TNC:\ANTHONY\NLP.D". Now I'm not too sure if it is the code that is adding these extra quotation marks, or just a setting in the cellvalue itself. Has anyone got any ideas how to get rid of these?

Your help is very much appreciated!


VBA Code:
Sub POSTB()
Sheets("PGM").Select
Columns.EntireColumn.Hidden = False
Rows.EntireRow.Hidden = False
For Each c In Range("A1:A115")
If c.Value = "" Then
c.EntireRow.Hidden = True
Else
c.EntireRow.Hidden = False
End If
Next
Dim wb As Workbook
Dim saveFile As String
Dim WorkRng As Range
On Error Resume Next
Set WorkRng = Worksheets("PGM").Range("A1:G115")
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set wb = Application.Workbooks.Add
WorkRng.SpecialCells(xlCellTypeVisible).Copy
wb.Worksheets(1).Paste
saveFile = Application.GetSaveAsFilename(fileFilter:="H (*.H), *.H")
wb.SaveAs Filename:=saveFile, FileFormat:=xlText, CreateBackup:=False
wb.Close
Application.CutCopyMode = False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Sheets("ZWALUW").Select
End Sub
 

Attachments

  • 1.PNG
    1.PNG
    6.3 KB · Views: 7
  • 2.PNG
    2.PNG
    24.1 KB · Views: 6
  • 3.PNG
    3.PNG
    13.1 KB · Views: 7
  • 4.PNG
    4.PNG
    9 KB · Views: 8
Last edited by a moderator:

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
When you save it as a text file, any cell that contains quotes will have them doubled. Why is your formula wrapping the path in quotes?
 
Upvote 0
When you save it as a text file, any cell that contains quotes will have them doubled. Why is your formula wrapping the path in quotes?
thanks for your reply!

the file will be send to a CNC machine and it gives an error if the path isn't wrapped in quotes.

The picture below is the output code that I sent to the machine. It cant read it this way.
 

Attachments

  • 1.PNG
    1.PNG
    17.3 KB · Views: 3
Last edited:
Upvote 0
Try saving it in .prn format (formatted text). You can always rename the file with a .txt extension afterwards?
 
Upvote 0
Try saving it in .prn format (formatted text). You can always rename the file with a .txt extension afterwards?
it is saved as .H, as that is the extension the CNC machine reads. I'm really no expert in VBA code writing, and mainly copy and paste code. Could you tell me whereabouts I should change the format to .prn in the VBA code?
 
Upvote 0
Use FileFormat:=xlTextPrinter in the SaveAs line.
 
Upvote 0

Forum statistics

Threads
1,215,071
Messages
6,122,964
Members
449,094
Latest member
Anshu121

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top