Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 183
Default compile/syntax error to save active book to new location on networ

I'm just a beginner at writing macros. And I'm really lost with proper
syntax in order to point to the desired directory location where we need the
file saved.

I recorded the macro, and then edited respective to tab names, etc. I'm
thinking it's maybe the syntax around the TimePeriod string. I'm also not
familiar with all the SaveAs conditions.

Here's the statement that where I get the error:

ActiveWorkbook.SaveAs([Q:\Finance\Forecast\2007\"&(TimePeriod"\TRG\Prelim
Actual vs
Forecast],[.xls],[""],[Normal],[""],[""],[False],[False],[""],[""],[""],[""])


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default compile/syntax error to save active book to new location on networ

Instead of using positional parameters (who remembers what order they go in???),
you can use keywords. VBA's help for .saveas shows them:

activeworkbook.saveas _
filename:="Q:\Finance\Forecast\2007\" & TimePeriod & _
"\TRG\Prelim Actual vs Forecast.xls", _
fileformat:=xlworkbooknormal

And depending on what timeperiod is, you may have to format it.

If it's a date, then your filename can't contain slashes--if it's a time, then
the filename can't contain the colons--something like:

activeworkbook.saveas _
filename:="Q:\Finance\Forecast\2007\" & format(TimePeriod, "yyyymmdd") & _
"\TRG\Prelim Actual vs Forecast.xls", _
fileformat:=xlworkbooknormal



Sharon wrote:

I'm just a beginner at writing macros. And I'm really lost with proper
syntax in order to point to the desired directory location where we need the
file saved.

I recorded the macro, and then edited respective to tab names, etc. I'm
thinking it's maybe the syntax around the TimePeriod string. I'm also not
familiar with all the SaveAs conditions.

Here's the statement that where I get the error:

ActiveWorkbook.SaveAs([Q:\Finance\Forecast\2007\"&(TimePeriod"\TRG\Prelim
Actual vs
Forecast],[.xls],[""],[Normal],[""],[""],[False],[False],[""],[""],[""],[""])


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 183
Default compile/syntax error to save active book to new location on ne

Thanks Dave works great....the TimePeriod format is a text value, so your
first "fix" worked wonderfully!
The only thing that was tricky is that there had to be a space before and
after the & operator ie; " & TimePeriod & "

Thank you So Much!!


"Dave Peterson" wrote:

Instead of using positional parameters (who remembers what order they go in???),
you can use keywords. VBA's help for .saveas shows them:

activeworkbook.saveas _
filename:="Q:\Finance\Forecast\2007\" & TimePeriod & _
"\TRG\Prelim Actual vs Forecast.xls", _
fileformat:=xlworkbooknormal

And depending on what timeperiod is, you may have to format it.

If it's a date, then your filename can't contain slashes--if it's a time, then
the filename can't contain the colons--something like:

activeworkbook.saveas _
filename:="Q:\Finance\Forecast\2007\" & format(TimePeriod, "yyyymmdd") & _
"\TRG\Prelim Actual vs Forecast.xls", _
fileformat:=xlworkbooknormal



Sharon wrote:

I'm just a beginner at writing macros. And I'm really lost with proper
syntax in order to point to the desired directory location where we need the
file saved.

I recorded the macro, and then edited respective to tab names, etc. I'm
thinking it's maybe the syntax around the TimePeriod string. I'm also not
familiar with all the SaveAs conditions.

Here's the statement that where I get the error:

ActiveWorkbook.SaveAs([Q:\Finance\Forecast\2007\"&(TimePeriod"\TRG\Prelim
Actual vs
Forecast],[.xls],[""],[Normal],[""],[""],[False],[False],[""],[""],[""],[""])


--

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
help with this error-Compile error: cant find project or library JackR Excel Discussion (Misc queries) 2 June 10th 06 09:09 PM
VBA Error Message "Compile Error...." Steve Excel Discussion (Misc queries) 3 July 15th 05 09:20 AM
Macro Error when moved Xcel Sheets from User's Home Dir to Networ Basheer New Users to Excel 1 April 29th 05 04:45 PM
How do I get rid of "Compile error in hidden module" error message David Excel Discussion (Misc queries) 4 January 21st 05 11:39 PM


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