ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   save as txt saves different tab, why??? (https://www.excelbanter.com/excel-discussion-misc-queries/161698-save-txt-saves-different-tab-why.html)

shark102

save as txt saves different tab, why???
 
hello

I have big workbook with many macros helping people to sort out some
complicated document. anyway last step after document has been edited, one
tab needs to be saved as txt file. I wrote a macro that does it (it is run
from a button on tab called 'summary'). tab that needs to be saved as txt is
called 'output'.
tab 'output' contains very long lines over 255 characters long.
problem is macro saves different tab sometimes and I have no idea why.
macro is simple and goes like that:

Dim fname '- define file name
fname = "cardex" & Mid(Worksheets("output").Range("a2"), 23, 8) & ".txt"

Dim cpath '-define path - range A7 contains path
cpath = Worksheets("summary").Range("a7")

Sheets("output").Select

ActiveWorkbook.SaveAs Filename:=cpath & fname, FileFormat:=xlText, _
CreateBackup:=False


any ideas greatly appreciated

Dave Peterson

save as txt saves different tab, why???
 
Your posted pseudo code looks ok to me. I'd check to see if you were actually
selecting the correct worksheet first.

I'd do this instead.

your dim's here
your assignments here

worksheets("output").copy 'to a new workbook
activeworkbook.saveas ....
activeworkbook.close savechanges:=false



shark102 wrote:

hello

I have big workbook with many macros helping people to sort out some
complicated document. anyway last step after document has been edited, one
tab needs to be saved as txt file. I wrote a macro that does it (it is run
from a button on tab called 'summary'). tab that needs to be saved as txt is
called 'output'.
tab 'output' contains very long lines over 255 characters long.
problem is macro saves different tab sometimes and I have no idea why.
macro is simple and goes like that:

Dim fname '- define file name
fname = "cardex" & Mid(Worksheets("output").Range("a2"), 23, 8) & ".txt"

Dim cpath '-define path - range A7 contains path
cpath = Worksheets("summary").Range("a7")

Sheets("output").Select

ActiveWorkbook.SaveAs Filename:=cpath & fname, FileFormat:=xlText, _
CreateBackup:=False

any ideas greatly appreciated


--

Dave Peterson

shark102

save as txt saves different tab, why???
 
thanks, it does the trick. I still wonder why my 'pseudocode' was saving
wrong tab sometime. is below line ambiguous maybe?

sheets("output").select ???

just out of curiosity, some codes are referred to as 'pseudocodes', what is
the difference?

thanks again

"Dave Peterson" wrote:

Your posted pseudo code looks ok to me. I'd check to see if you were actually
selecting the correct worksheet first.

I'd do this instead.

your dim's here
your assignments here

worksheets("output").copy 'to a new workbook
activeworkbook.saveas ....
activeworkbook.close savechanges:=false



shark102 wrote:

hello

I have big workbook with many macros helping people to sort out some
complicated document. anyway last step after document has been edited, one
tab needs to be saved as txt file. I wrote a macro that does it (it is run
from a button on tab called 'summary'). tab that needs to be saved as txt is
called 'output'.
tab 'output' contains very long lines over 255 characters long.
problem is macro saves different tab sometimes and I have no idea why.
macro is simple and goes like that:

Dim fname '- define file name
fname = "cardex" & Mid(Worksheets("output").Range("a2"), 23, 8) & ".txt"

Dim cpath '-define path - range A7 contains path
cpath = Worksheets("summary").Range("a7")

Sheets("output").Select

ActiveWorkbook.SaveAs Filename:=cpath & fname, FileFormat:=xlText, _
CreateBackup:=False

any ideas greatly appreciated


--

Dave Peterson


Dave Peterson

save as txt saves different tab, why???
 
I didn't see anything wrong that popped out when I looked at your code. I don't
have a guess why the code that you posted would fail--maybe there was something
in the code that you didn't post????

Psuedo code is false code--it's not ready to just copy and paste into a module
and run as-is.

It can include as much detail (or as few details) as the author wants/needs.

Open a workbook file
work on the pricing sheet
Update the values for customer xxx by 5% to a maximum of 280% of the cost.
Create a report sheet for those parts
Save the workbook file as a new name
Close the workbook

is a pretty high level of psuedo code. It may be enough for one person to
continue to develop the project. Other people may want to add more details.



shark102 wrote:

thanks, it does the trick. I still wonder why my 'pseudocode' was saving
wrong tab sometime. is below line ambiguous maybe?

sheets("output").select ???

just out of curiosity, some codes are referred to as 'pseudocodes', what is
the difference?

thanks again

"Dave Peterson" wrote:

Your posted pseudo code looks ok to me. I'd check to see if you were actually
selecting the correct worksheet first.

I'd do this instead.

your dim's here
your assignments here

worksheets("output").copy 'to a new workbook
activeworkbook.saveas ....
activeworkbook.close savechanges:=false



shark102 wrote:

hello

I have big workbook with many macros helping people to sort out some
complicated document. anyway last step after document has been edited, one
tab needs to be saved as txt file. I wrote a macro that does it (it is run
from a button on tab called 'summary'). tab that needs to be saved as txt is
called 'output'.
tab 'output' contains very long lines over 255 characters long.
problem is macro saves different tab sometimes and I have no idea why.
macro is simple and goes like that:

Dim fname '- define file name
fname = "cardex" & Mid(Worksheets("output").Range("a2"), 23, 8) & ".txt"

Dim cpath '-define path - range A7 contains path
cpath = Worksheets("summary").Range("a7")

Sheets("output").Select

ActiveWorkbook.SaveAs Filename:=cpath & fname, FileFormat:=xlText, _
CreateBackup:=False

any ideas greatly appreciated


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 04:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com