Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Saving file to *.prn format

Hello NG,

Can someone explain why I can not make this piece of code to work and help
me correct it. The debugger always stop on the SaveAs command.
testfile.xls is just a tabulation of numbers formatted as text.

TIA.

Jon-jon


Sub Test_xls2prn()
Workbooks.Open Filename:="c:\testfile.xls", ReadOnly:=True
With ActiveWorkbook
.Sheets(1).Cells(1, 1).Select
Application.DisplayAlerts = False
.SaveAs Filename:="c:\testfile.prn", _
FileFormat:=xlTextPrinter, CreateBackup:=False
Application.DisplayAlerts = True
End With
ActiveWorkbook.Close True
Kill "c:\testfile.xls"
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Saving file to *.prn format

Try moving line 4 to line 2...

Sub Test_xls2prn()
Workbooks.Open Filename:="c:\testfile.xls", ReadOnly:=True
Application.DisplayAlerts = False
With ActiveWorkbook
.Sheets(1).Cells(1, 1).Select
.SaveAs Filename:="c:\testfile.prn", _
FileFormat:=xlTextPrinter, CreateBackup:=False
Application.DisplayAlerts = True
End With
ActiveWorkbook.Close True
Kill "c:\testfile.xls"
End Sub

Mike F
"JON JON" wrote in message
...
Hello NG,

Can someone explain why I can not make this piece of code to work and help
me correct it. The debugger always stop on the SaveAs command.
testfile.xls is just a tabulation of numbers formatted as text.

TIA.

Jon-jon


Sub Test_xls2prn()
Workbooks.Open Filename:="c:\testfile.xls", ReadOnly:=True
With ActiveWorkbook
.Sheets(1).Cells(1, 1).Select
Application.DisplayAlerts = False
.SaveAs Filename:="c:\testfile.prn", _
FileFormat:=xlTextPrinter, CreateBackup:=False
Application.DisplayAlerts = True
End With
ActiveWorkbook.Close True
Kill "c:\testfile.xls"
End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Saving file to *.prn format

Your code worked as-is for me.

Any chance that testfile.prn is marked readonly (or that you have it open
somewhere else)?

What's the error message that you get?

JON JON wrote:

Hello NG,

Can someone explain why I can not make this piece of code to work and help
me correct it. The debugger always stop on the SaveAs command.
testfile.xls is just a tabulation of numbers formatted as text.

TIA.

Jon-jon

Sub Test_xls2prn()
Workbooks.Open Filename:="c:\testfile.xls", ReadOnly:=True
With ActiveWorkbook
.Sheets(1).Cells(1, 1).Select
Application.DisplayAlerts = False
.SaveAs Filename:="c:\testfile.prn", _
FileFormat:=xlTextPrinter, CreateBackup:=False
Application.DisplayAlerts = True
End With
ActiveWorkbook.Close True
Kill "c:\testfile.xls"
End Sub


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Saving file to *.prn format

Hello Dave,

Thank you for trying to help.

With regards to your question, testfile.prn does not yet exist so it can
neither be opened nor marked read-only. The error message is "Run time
error 1004. Method Save As object workbook failed.

Thanks,

Jon-jon

"Dave Peterson" wrote in message
...
Your code worked as-is for me.

Any chance that testfile.prn is marked readonly (or that you have it open
somewhere else)?

What's the error message that you get?

JON JON wrote:

Hello NG,

Can someone explain why I can not make this piece of code to work and
help
me correct it. The debugger always stop on the SaveAs command.
testfile.xls is just a tabulation of numbers formatted as text.

TIA.

Jon-jon

Sub Test_xls2prn()
Workbooks.Open Filename:="c:\testfile.xls", ReadOnly:=True
With ActiveWorkbook
.Sheets(1).Cells(1, 1).Select
Application.DisplayAlerts = False
.SaveAs Filename:="c:\testfile.prn", _
FileFormat:=xlTextPrinter, CreateBackup:=False
Application.DisplayAlerts = True
End With
ActiveWorkbook.Close True
Kill "c:\testfile.xls"
End Sub


--

Dave Peterson



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Saving file to *.prn format

Hello Mike,

I do not fully understand why can you please explain.

Thanks,

Jon-jon



"Mike Fogleman" wrote in message
...
Try moving line 4 to line 2...

Sub Test_xls2prn()
Workbooks.Open Filename:="c:\testfile.xls", ReadOnly:=True
Application.DisplayAlerts = False
With ActiveWorkbook
.Sheets(1).Cells(1, 1).Select
.SaveAs Filename:="c:\testfile.prn", _
FileFormat:=xlTextPrinter, CreateBackup:=False
Application.DisplayAlerts = True
End With
ActiveWorkbook.Close True
Kill "c:\testfile.xls"
End Sub

Mike F
"JON JON" wrote in message
...
Hello NG,

Can someone explain why I can not make this piece of code to work and
help
me correct it. The debugger always stop on the SaveAs command.
testfile.xls is just a tabulation of numbers formatted as text.

TIA.

Jon-jon


Sub Test_xls2prn()
Workbooks.Open Filename:="c:\testfile.xls", ReadOnly:=True
With ActiveWorkbook
.Sheets(1).Cells(1, 1).Select
Application.DisplayAlerts = False
.SaveAs Filename:="c:\testfile.prn", _
FileFormat:=xlTextPrinter, CreateBackup:=False
Application.DisplayAlerts = True
End With
ActiveWorkbook.Close True
Kill "c:\testfile.xls"
End Sub








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Saving file to *.prn format

I don't have any real good guesses.

But I do have some bad ones!

Is there enough space on that drive?
Do you have write access to your harddrive?
If you do it manually, what happens?

If it worked manually, record macro and compare it with your code to see if
there's a difference.

(I got nothin')

JON JON wrote:

Hello Dave,

Thank you for trying to help.

With regards to your question, testfile.prn does not yet exist so it can
neither be opened nor marked read-only. The error message is "Run time
error 1004. Method Save As object workbook failed.

Thanks,

Jon-jon

"Dave Peterson" wrote in message
...
Your code worked as-is for me.

Any chance that testfile.prn is marked readonly (or that you have it open
somewhere else)?

What's the error message that you get?

JON JON wrote:

Hello NG,

Can someone explain why I can not make this piece of code to work and
help
me correct it. The debugger always stop on the SaveAs command.
testfile.xls is just a tabulation of numbers formatted as text.

TIA.

Jon-jon

Sub Test_xls2prn()
Workbooks.Open Filename:="c:\testfile.xls", ReadOnly:=True
With ActiveWorkbook
.Sheets(1).Cells(1, 1).Select
Application.DisplayAlerts = False
.SaveAs Filename:="c:\testfile.prn", _
FileFormat:=xlTextPrinter, CreateBackup:=False
Application.DisplayAlerts = True
End With
ActiveWorkbook.Close True
Kill "c:\testfile.xls"
End Sub


--

Dave Peterson


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Saving file to *.prn format

Jon,
Are you trying to save over a network ?

NickHK

"JON JON" wrote in message
...
Hello Dave,

Thank you for trying to help.

With regards to your question, testfile.prn does not yet exist so it can
neither be opened nor marked read-only. The error message is "Run time
error 1004. Method Save As object workbook failed.

Thanks,

Jon-jon

"Dave Peterson" wrote in message
...
Your code worked as-is for me.

Any chance that testfile.prn is marked readonly (or that you have it

open
somewhere else)?

What's the error message that you get?

JON JON wrote:

Hello NG,

Can someone explain why I can not make this piece of code to work and
help
me correct it. The debugger always stop on the SaveAs command.
testfile.xls is just a tabulation of numbers formatted as text.

TIA.

Jon-jon

Sub Test_xls2prn()
Workbooks.Open Filename:="c:\testfile.xls", ReadOnly:=True
With ActiveWorkbook
.Sheets(1).Cells(1, 1).Select
Application.DisplayAlerts = False
.SaveAs Filename:="c:\testfile.prn", _
FileFormat:=xlTextPrinter, CreateBackup:=False
Application.DisplayAlerts = True
End With
ActiveWorkbook.Close True
Kill "c:\testfile.xls"
End Sub


--

Dave Peterson





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Saving file to *.prn format

His code showed c:\



NickHK wrote:

Jon,
Are you trying to save over a network ?

NickHK

"JON JON" wrote in message
...
Hello Dave,

Thank you for trying to help.

With regards to your question, testfile.prn does not yet exist so it can
neither be opened nor marked read-only. The error message is "Run time
error 1004. Method Save As object workbook failed.

Thanks,

Jon-jon

"Dave Peterson" wrote in message
...
Your code worked as-is for me.

Any chance that testfile.prn is marked readonly (or that you have it

open
somewhere else)?

What's the error message that you get?

JON JON wrote:

Hello NG,

Can someone explain why I can not make this piece of code to work and
help
me correct it. The debugger always stop on the SaveAs command.
testfile.xls is just a tabulation of numbers formatted as text.

TIA.

Jon-jon

Sub Test_xls2prn()
Workbooks.Open Filename:="c:\testfile.xls", ReadOnly:=True
With ActiveWorkbook
.Sheets(1).Cells(1, 1).Select
Application.DisplayAlerts = False
.SaveAs Filename:="c:\testfile.prn", _
FileFormat:=xlTextPrinter, CreateBackup:=False
Application.DisplayAlerts = True
End With
ActiveWorkbook.Close True
Kill "c:\testfile.xls"
End Sub

--

Dave Peterson




--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Saving file to *.prn format

Hello Dave

I got 25.6 GB of free space.
I do have Admin access to my PC.
I have tried to save it manually and it works fine. However, when I run
the recorded macro, it also shows the same error as the one I have written.

I am getting frustrated. I am suspecting that it has something to do with
the file I am saving but can't figure it out.

Jon-jon


"Dave Peterson" wrote in message
...
I don't have any real good guesses.

But I do have some bad ones!

Is there enough space on that drive?
Do you have write access to your harddrive?
If you do it manually, what happens?

If it worked manually, record macro and compare it with your code to see
if
there's a difference.

(I got nothin')

JON JON wrote:

Hello Dave,

Thank you for trying to help.

With regards to your question, testfile.prn does not yet exist so it can
neither be opened nor marked read-only. The error message is "Run time
error 1004. Method Save As object workbook failed.

Thanks,

Jon-jon

"Dave Peterson" wrote in message
...
Your code worked as-is for me.

Any chance that testfile.prn is marked readonly (or that you have it
open
somewhere else)?

What's the error message that you get?

JON JON wrote:

Hello NG,

Can someone explain why I can not make this piece of code to work and
help
me correct it. The debugger always stop on the SaveAs command.
testfile.xls is just a tabulation of numbers formatted as text.

TIA.

Jon-jon

Sub Test_xls2prn()
Workbooks.Open Filename:="c:\testfile.xls", ReadOnly:=True
With ActiveWorkbook
.Sheets(1).Cells(1, 1).Select
Application.DisplayAlerts = False
.SaveAs Filename:="c:\testfile.prn", _
FileFormat:=xlTextPrinter, CreateBackup:=False
Application.DisplayAlerts = True
End With
ActiveWorkbook.Close True
Kill "c:\testfile.xls"
End Sub

--

Dave Peterson


--

Dave Peterson



  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Saving file to *.prn format

I can't think of anything that would interrupt that save (that I haven't
guessed) (well, one more. You don't have c:\testfile.prn as a hidden readonly
file -- so it's not visible in windows explorer.)

If you change the name to C:\asdfasdf.prn, does it save?

If you copy the code to another workbook and try it there, does it save?

If you try to save to a different folder, does it save?

(I still got nothin'.)



JON JON wrote:

Hello Dave

I got 25.6 GB of free space.
I do have Admin access to my PC.
I have tried to save it manually and it works fine. However, when I run
the recorded macro, it also shows the same error as the one I have written.

I am getting frustrated. I am suspecting that it has something to do with
the file I am saving but can't figure it out.

Jon-jon

"Dave Peterson" wrote in message
...
I don't have any real good guesses.

But I do have some bad ones!

Is there enough space on that drive?
Do you have write access to your harddrive?
If you do it manually, what happens?

If it worked manually, record macro and compare it with your code to see
if
there's a difference.

(I got nothin')

JON JON wrote:

Hello Dave,

Thank you for trying to help.

With regards to your question, testfile.prn does not yet exist so it can
neither be opened nor marked read-only. The error message is "Run time
error 1004. Method Save As object workbook failed.

Thanks,

Jon-jon

"Dave Peterson" wrote in message
...
Your code worked as-is for me.

Any chance that testfile.prn is marked readonly (or that you have it
open
somewhere else)?

What's the error message that you get?

JON JON wrote:

Hello NG,

Can someone explain why I can not make this piece of code to work and
help
me correct it. The debugger always stop on the SaveAs command.
testfile.xls is just a tabulation of numbers formatted as text.

TIA.

Jon-jon

Sub Test_xls2prn()
Workbooks.Open Filename:="c:\testfile.xls", ReadOnly:=True
With ActiveWorkbook
.Sheets(1).Cells(1, 1).Select
Application.DisplayAlerts = False
.SaveAs Filename:="c:\testfile.prn", _
FileFormat:=xlTextPrinter, CreateBackup:=False
Application.DisplayAlerts = True
End With
ActiveWorkbook.Close True
Kill "c:\testfile.xls"
End Sub

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 62
Default Saving file to *.prn format

Hello Dave,

I really appreciate your patience in helping me. I tried all your
suggestions and still nothing works.

I also try to replace testfile.xls with a new file that I put only some text
on it and the code works. So I guess, I am right that it was something to
do with the file I am trying to convert.

If only I can send you the file so you can examine. It will greatly help
me a lot.

Regards,

Jon-jon



"Dave Peterson" wrote in message
...
I can't think of anything that would interrupt that save (that I haven't
guessed) (well, one more. You don't have c:\testfile.prn as a hidden
readonly
file -- so it's not visible in windows explorer.)

If you change the name to C:\asdfasdf.prn, does it save?

If you copy the code to another workbook and try it there, does it save?

If you try to save to a different folder, does it save?

(I still got nothin'.)



JON JON wrote:

Hello Dave

I got 25.6 GB of free space.
I do have Admin access to my PC.
I have tried to save it manually and it works fine. However, when I run
the recorded macro, it also shows the same error as the one I have
written.

I am getting frustrated. I am suspecting that it has something to do
with
the file I am saving but can't figure it out.

Jon-jon

"Dave Peterson" wrote in message
...
I don't have any real good guesses.

But I do have some bad ones!

Is there enough space on that drive?
Do you have write access to your harddrive?
If you do it manually, what happens?

If it worked manually, record macro and compare it with your code to
see
if
there's a difference.

(I got nothin')

JON JON wrote:

Hello Dave,

Thank you for trying to help.

With regards to your question, testfile.prn does not yet exist so it
can
neither be opened nor marked read-only. The error message is "Run
time
error 1004. Method Save As object workbook failed.

Thanks,

Jon-jon

"Dave Peterson" wrote in message
...
Your code worked as-is for me.

Any chance that testfile.prn is marked readonly (or that you have it
open
somewhere else)?

What's the error message that you get?

JON JON wrote:

Hello NG,

Can someone explain why I can not make this piece of code to work
and
help
me correct it. The debugger always stop on the SaveAs command.
testfile.xls is just a tabulation of numbers formatted as text.

TIA.

Jon-jon

Sub Test_xls2prn()
Workbooks.Open Filename:="c:\testfile.xls", ReadOnly:=True
With ActiveWorkbook
.Sheets(1).Cells(1, 1).Select
Application.DisplayAlerts = False
.SaveAs Filename:="c:\testfile.prn", _
FileFormat:=xlTextPrinter, CreateBackup:=False
Application.DisplayAlerts = True
End With
ActiveWorkbook.Close True
Kill "c:\testfile.xls"
End Sub

--

Dave Peterson

--

Dave Peterson


--

Dave Peterson



  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Saving file to *.prn format

You could send me the file, but I don't think that it'll help.

Please keep it small--I'm on dialup. Zip it if you have to.

remove the XSPAM in my email address.


JON JON wrote:

Hello Dave,

I really appreciate your patience in helping me. I tried all your
suggestions and still nothing works.

I also try to replace testfile.xls with a new file that I put only some text
on it and the code works. So I guess, I am right that it was something to
do with the file I am trying to convert.

If only I can send you the file so you can examine. It will greatly help
me a lot.

Regards,

Jon-jon

"Dave Peterson" wrote in message
...
I can't think of anything that would interrupt that save (that I haven't
guessed) (well, one more. You don't have c:\testfile.prn as a hidden
readonly
file -- so it's not visible in windows explorer.)

If you change the name to C:\asdfasdf.prn, does it save?

If you copy the code to another workbook and try it there, does it save?

If you try to save to a different folder, does it save?

(I still got nothin'.)



JON JON wrote:

Hello Dave

I got 25.6 GB of free space.
I do have Admin access to my PC.
I have tried to save it manually and it works fine. However, when I run
the recorded macro, it also shows the same error as the one I have
written.

I am getting frustrated. I am suspecting that it has something to do
with
the file I am saving but can't figure it out.

Jon-jon

"Dave Peterson" wrote in message
...
I don't have any real good guesses.

But I do have some bad ones!

Is there enough space on that drive?
Do you have write access to your harddrive?
If you do it manually, what happens?

If it worked manually, record macro and compare it with your code to
see
if
there's a difference.

(I got nothin')

JON JON wrote:

Hello Dave,

Thank you for trying to help.

With regards to your question, testfile.prn does not yet exist so it
can
neither be opened nor marked read-only. The error message is "Run
time
error 1004. Method Save As object workbook failed.

Thanks,

Jon-jon

"Dave Peterson" wrote in message
...
Your code worked as-is for me.

Any chance that testfile.prn is marked readonly (or that you have it
open
somewhere else)?

What's the error message that you get?

JON JON wrote:

Hello NG,

Can someone explain why I can not make this piece of code to work
and
help
me correct it. The debugger always stop on the SaveAs command.
testfile.xls is just a tabulation of numbers formatted as text.

TIA.

Jon-jon

Sub Test_xls2prn()
Workbooks.Open Filename:="c:\testfile.xls", ReadOnly:=True
With ActiveWorkbook
.Sheets(1).Cells(1, 1).Select
Application.DisplayAlerts = False
.SaveAs Filename:="c:\testfile.prn", _
FileFormat:=xlTextPrinter, CreateBackup:=False
Application.DisplayAlerts = True
End With
ActiveWorkbook.Close True
Kill "c:\testfile.xls"
End Sub

--

Dave Peterson

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Saving file to *.prn format

Your code worked for me so I was guessing why it might not for you. My guess
was based on the error you got. Your With... End With statement was possibly
broken by the DisplayAlerts line and therefore would fail on the .SaveAs
line. Keeping the DOT lines contiguous was my thinking.
Mike F
"JON JON" wrote in message
...
Hello Mike,

I do not fully understand why can you please explain.

Thanks,

Jon-jon



"Mike Fogleman" wrote in message
...
Try moving line 4 to line 2...

Sub Test_xls2prn()
Workbooks.Open Filename:="c:\testfile.xls", ReadOnly:=True
Application.DisplayAlerts = False
With ActiveWorkbook
.Sheets(1).Cells(1, 1).Select
.SaveAs Filename:="c:\testfile.prn", _
FileFormat:=xlTextPrinter, CreateBackup:=False
Application.DisplayAlerts = True
End With
ActiveWorkbook.Close True
Kill "c:\testfile.xls"
End Sub

Mike F
"JON JON" wrote in message
...
Hello NG,

Can someone explain why I can not make this piece of code to work and
help
me correct it. The debugger always stop on the SaveAs command.
testfile.xls is just a tabulation of numbers formatted as text.

TIA.

Jon-jon


Sub Test_xls2prn()
Workbooks.Open Filename:="c:\testfile.xls", ReadOnly:=True
With ActiveWorkbook
.Sheets(1).Cells(1, 1).Select
Application.DisplayAlerts = False
.SaveAs Filename:="c:\testfile.prn", _
FileFormat:=xlTextPrinter, CreateBackup:=False
Application.DisplayAlerts = True
End With
ActiveWorkbook.Close True
Kill "c:\testfile.xls"
End Sub








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
Saving in new file format moon Excel Discussion (Misc queries) 2 November 11th 09 06:12 PM
Saving File Format Raz Excel Worksheet Functions 2 November 27th 08 05:32 PM
Cell changes format upon saving file victorsm Excel Discussion (Misc queries) 3 November 13th 08 03:50 AM
Saving file in CSV format meeta das Excel Discussion (Misc queries) 2 February 15th 06 12:41 PM
Saving file in the format "YYMM" Dolphinv4 Excel Discussion (Misc queries) 2 October 5th 05 12:08 PM


All times are GMT +1. The time now is 06:29 AM.

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"