Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default My small code make excel crash

Hi,

The code under make excel crash. I have found out that the last line
"ActiveWorkbook.Close" is the reason, but i dont understand why. And i like
to solve it aswell...
How can i close the workbook without crashing excel.....???

:-)


Sub FlyttetilHLT()

Dim adr
Dim fadr
Dim klient
klient = Range("c4").Value
adr = ActiveWorkbook.Path
Worksheets(2).Activate
fadr = adr & "\" & "IT" & klient & "TRS.HLT"
ActiveWorkbook.SaveAs Filename:=fadr, _
FileFormat:=xlText, CreateBackup:=False
ActiveWorkbook.Close
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
jaf jaf is offline
external usenet poster
 
Posts: 300
Default My small code make excel crash

Hi Petter,
I think you need slashes before and after klient.

fadr = adr & "\" & "IT" & klient & "TRS.HLT"

Should be...

fadr = adr & "\" & "IT" & "\" & klient & "\" & "TRS.HLT"


"Petter" wrote in message ...
Hi,

The code under make excel crash. I have found out that the last line
"ActiveWorkbook.Close" is the reason, but i dont understand why. And i like
to solve it aswell...
How can i close the workbook without crashing excel.....???

:-)


Sub FlyttetilHLT()

Dim adr
Dim fadr
Dim klient
klient = Range("c4").Value
adr = ActiveWorkbook.Path
Worksheets(2).Activate
fadr = adr & "\" & "IT" & klient & "TRS.HLT"
ActiveWorkbook.SaveAs Filename:=fadr, _
FileFormat:=xlText, CreateBackup:=False
ActiveWorkbook.Close
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default My small code make excel crash

Hi Jaf,

That is not the problem...
The file name would be somthing like IT006TRS.HLT and that is correct.
That bit work like a charm....

It has something with that i trying to close the workbook that i have
saved..could it be something with that is not longer a workbook??..since i
saved it as a .txt file???

"jaf" wrote:

Hi Petter,
I think you need slashes before and after klient.

fadr = adr & "\" & "IT" & klient & "TRS.HLT"

Should be...

fadr = adr & "\" & "IT" & "\" & klient & "\" & "TRS.HLT"


"Petter" wrote in message ...
Hi,

The code under make excel crash. I have found out that the last line
"ActiveWorkbook.Close" is the reason, but i dont understand why. And i like
to solve it aswell...
How can i close the workbook without crashing excel.....???

:-)


Sub FlyttetilHLT()

Dim adr
Dim fadr
Dim klient
klient = Range("c4").Value
adr = ActiveWorkbook.Path
Worksheets(2).Activate
fadr = adr & "\" & "IT" & klient & "TRS.HLT"
ActiveWorkbook.SaveAs Filename:=fadr, _
FileFormat:=xlText, CreateBackup:=False
ActiveWorkbook.Close
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default My small code make excel crash


By using the line
Debug.print fadr
and viewing the result in the Immediate window
or
MsgBox fadr
you can check the result of your code before trying to save the file.


--
mdmackillop
------------------------------------------------------------------------
mdmackillop's Profile: http://www.thecodecage.com/forumz/member.php?userid=113
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=68050

  #5   Report Post  
Posted to microsoft.public.excel.programming
jaf jaf is offline
external usenet poster
 
Posts: 300
Default My small code make excel crash

Hi Petter,
If you are running code, you have to have at least one workbook open.
Are you closing the workbook that contains the code?

Application.quit will close Excel completely without an error.
John


"Petter" wrote in message ...
Hi Jaf,

That is not the problem...
The file name would be somthing like IT006TRS.HLT and that is correct.
That bit work like a charm....

It has something with that i trying to close the workbook that i have
saved..could it be something with that is not longer a workbook??..since i
saved it as a .txt file???

"jaf" wrote:

Hi Petter,
I think you need slashes before and after klient.

fadr = adr & "\" & "IT" & klient & "TRS.HLT"

Should be...

fadr = adr & "\" & "IT" & "\" & klient & "\" & "TRS.HLT"


"Petter" wrote in message ...
Hi,

The code under make excel crash. I have found out that the last line
"ActiveWorkbook.Close" is the reason, but i dont understand why. And i like
to solve it aswell...
How can i close the workbook without crashing excel.....???

:-)


Sub FlyttetilHLT()

Dim adr
Dim fadr
Dim klient
klient = Range("c4").Value
adr = ActiveWorkbook.Path
Worksheets(2).Activate
fadr = adr & "\" & "IT" & klient & "TRS.HLT"
ActiveWorkbook.SaveAs Filename:=fadr, _
FileFormat:=xlText, CreateBackup:=False
ActiveWorkbook.Close
End Sub




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default My small code make excel crash

hi Petter

Excel version ?

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Petter" wrote in message ...
Hi,

The code under make excel crash. I have found out that the last line
"ActiveWorkbook.Close" is the reason, but i dont understand why. And i like
to solve it aswell...
How can i close the workbook without crashing excel.....???

:-)


Sub FlyttetilHLT()

Dim adr
Dim fadr
Dim klient
klient = Range("c4").Value
adr = ActiveWorkbook.Path
Worksheets(2).Activate
fadr = adr & "\" & "IT" & klient & "TRS.HLT"
ActiveWorkbook.SaveAs Filename:=fadr, _
FileFormat:=xlText, CreateBackup:=False
ActiveWorkbook.Close
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
Why this code crash Excel? [email protected] Excel Programming 0 July 2nd 07 04:54 PM
this code makes excel crash zz Excel Programming 0 December 22nd 06 11:14 PM
How can I make program of accounting in excel for small business Najaf Anwar Excel Programming 1 February 27th 06 02:41 AM
stubborn Excel crash when editing code with code, one solution Brian Murphy Excel Programming 0 February 20th 05 05:56 AM
Excel crash error code Ed[_17_] Excel Programming 1 February 16th 04 10:46 AM


All times are GMT +1. The time now is 06:40 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"