ActiveWorkbook.SaveAs leaving whitespace in text file

Wildwood

New Member
Joined
Apr 16, 2014
Messages
1
The following is a snip of the code I'm using for generating txt files from a procedure in a multisheet workbook with multiple tabs. Generally speaking the process works fine except the method I have to select the sheet to manage the ActiveWorkbook.SaveAs function. This method leaves each text file with excessive whitespace at the end of each line and for the purpose I have for the text files it creates a problem.
Each sheet has a named range for the data I am looking to save off to each file but my experimentation with other methods to arrive at a solution to save the named range just doesn't work.

Anyone have an idea? Best regards and thanks in advance....Wildwood
Private Sub CommandButton1_Click()
SaveName1 = Sheets("HUB or HUB ODD VLAN").Range("A2")
SaveName2 = Sheets("HUB EVEN VLAN").Range("A2")
SaveName3 = Sheets("HICAP MIDDLE ROUTER").Range("A2")
SaveName4 = Sheets("SPOKE#1").Range("A2")
SaveName5 = Sheets("SPOKE#2").Range("A2")
SaveName6 = Sheets("SPOKE#3").Range("A2")
SaveName7 = Sheets("SPOKE#4").Range("A2")
SaveName8 = Sheets("SPOKE#5").Range("A2")
SaveName9 = Sheets("SPOKE#6").Range("A2")
SaveName10 = Sheets("SPOKE#7").Range("A2")
SaveName11 = Sheets("SPOKE#8").Range("A2")
SaveName12 = Sheets("SPOKE#9").Range("A2")
SaveName13 = Sheets("SPOKE#10").Range("A2")
varPath = ActiveSheet.Range("PATH")
SKIP11 = Sheets("Input").Range("HOST_HUB_EVEN")
SKIP12 = Sheets("Input").Range("HOST_MIDDLE")
SKIP13 = Sheets("Input").Range("HOST11")
SKIP14 = Sheets("Input").Range("HOST12")
SKIP15 = Sheets("Input").Range("HOST13")
SKIP16 = Sheets("Input").Range("HOST14")
SKIP17 = Sheets("Input").Range("HOST15")
SKIP18 = Sheets("Input").Range("HOST16")
SKIP19 = Sheets("Input").Range("HOST17")
SKIP20 = Sheets("Input").Range("HOST18")
SKIP21 = Sheets("Input").Range("HOST19")
SKIP22 = Sheets("Input").Range("HOST20")

Sheets("HUB or HUB ODD VLAN").Select
ActiveWorkbook.SaveAs Filename:=varPath & SaveName1 & ".txt" _
, FileFormat:=xlTextMSDOS, CreateBackup:=False

If SKIP11 = "" Then GoTo NEXT1:

Sheets("HUB EVEN VLAN").Select
ActiveWorkbook.SaveAs Filename:=varPath & SaveName2 & ".txt" _
, FileFormat:=xlTextMSDOS, CreateBackup:=False

NEXT1:
If SKIP12 = "" Then GoTo NEXT2:

Sheets("HICAP MIDDLE ROUTER").Select
ActiveWorkbook.SaveAs Filename:=varPath & SaveName3 & ".txt" _
, FileFormat:=xlTextMSDOS, CreateBackup:=False

NEXT2:
If SKIP13 = "" Then GoTo NEXT3:

Sheets("SPOKE#1").Select
ActiveWorkbook.SaveAs Filename:=varPath & SaveName4 & ".txt" _
, FileFormat:=xlTextMSDOS, CreateBackup:=False
 

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