Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 16
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Saves Once only Phil G Excel Discussion (Misc queries) 2 August 30th 07 11:50 AM
What happens when Excel 07 saves? Cherry Black Excel Discussion (Misc queries) 3 August 23rd 07 06:05 PM
counting saves msfphish Excel Discussion (Misc queries) 2 March 28th 06 05:42 PM
when I save a file from Excel 2003 to cd it saves as read only mmjjmm Excel Worksheet Functions 1 February 14th 06 01:15 AM
Save As CSV saves empty rows Garrett Excel Discussion (Misc queries) 3 February 18th 05 12:18 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"