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: 11
  • 2.PNG
    2.PNG
    24.1 KB · Views: 14
  • 3.PNG
    3.PNG
    13.1 KB · Views: 15
  • 4.PNG
    4.PNG
    9 KB · Views: 21
Last edited by a moderator:

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
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: 14
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,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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