If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > lines of code not executing??

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-04-04, 13:35
MrCrud MrCrud is offline
Registered User
 
Join Date: Nov 2003
Posts: 150
Angry lines of code not executing??

Hi,

i have this VBA macro on an excel sheet. Here is the code that gives me trouble:

------------------------------------------------------------------------------------

Sub SaveMe2()

With Application
.DisplayAlerts = True
.ScreenUpdating = True
End With

Dim fname1 As String
Dim fname2 As String

' Save as Range Name
fname1 = Sheets("invoice").Range("N57")

' Save as user Input
fname2 = InputBox("Please enter the target Filename", "Filename Entry")

On Error Goto Error:

With ActiveWorkbook
.SaveAs Filename:="\\ADMIN\My Documents\Comptabilité\FactureClients\" & fname2 & ".xls"
.SaveAs Filename:="C:\Documents and Settings\Mr.Crud\My Documents\E-Comm\Audio Occasion\Factures Clients" & fname2 & ".xls"
End With

ActiveWindow.SelectedSheets.PrintOut Copies:=3, Collate:=True

Workbooks.Open Filename:="C:\Documents and Settings\Mr.Crud\My Documents\E-Comm\Audio Occasion\Test\Factures Clients.xls"

Workbooks("" & fname2 & ".xls").Close True

Error:

End Sub

-----------------------------------------------------------------------------------

when i step into the code, it doesnt execute the last 2 commands ( the Workbooks.Open.... and the Workbooks.Close.... ) it just skips right over.

anyone know why??

I'm running this on Excel 2003, but the code was originally written on a Excel XP machine.

Thanks!
__________________
Cheers!

Mr.Crud

There are 10 kinds of people, ones that understand digital, others that dont
Reply With Quote
  #2 (permalink)  
Old 02-04-04, 17:00
Smitty Smitty is offline
Registered User
 
Join Date: Dec 2003
Location: San Diego, CA
Posts: 153
As long as the file exists, it should open.

The second part should be:

Workbooks(fname2).Close True

And Display =Alerts & ScreenUpdating should be false at the beginning of the code and set to True at the end.

I'll repost the entire code I gave you before if it will help.

Smitty
Reply With Quote
  #3 (permalink)  
Old 02-04-04, 17:24
MrCrud MrCrud is offline
Registered User
 
Join Date: Nov 2003
Posts: 150
Hi again Smitty,

The thing i dont get is that it runs fine on my computer, but not on the machine i designed this file for!!!

When running the code one line at a time, it just skips right over the lines??!!!

Workbooks(fname2).Close True line, i cant get it to work this way, i have to put in the rest.

Is there a difference between Excel 2003 and XP that would cause this, such as a change in the commands???

thanks for the reply!

Cheers!
__________________
Cheers!

Mr.Crud

There are 10 kinds of people, ones that understand digital, others that dont
Reply With Quote
  #4 (permalink)  
Old 02-04-04, 17:47
Smitty Smitty is offline
Registered User
 
Join Date: Dec 2003
Location: San Diego, CA
Posts: 153
Quote:
Is there a difference between Excel 2003 and XP that would cause this, such as a change in the commands???
Not that I'm aware of, but I could be wrong. I'd look at the Microsoft Knowledge Base and see if you get any answers there.

Smitty
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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