Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Coding Etiquette

Hi All,

I was running Excel 2000. All my macros always refered to excel files as
myfile.xls. We are switching to 2007 and now all files are *.xlsx or xlsm
or xlsb blah blah blah.

How should I change my coding? Do I hard code in the file name as
myfile.xlsm? What happens if the Excel 2010 uses *.xlsmm or somthing stupid
like that. Then do I recode everything again?

There has to be an easier way.

Thanks
Chad


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Coding Etiquette

Sorry here is my line of code in question

Application.Run "'SLOPE_MONITORING_4XX_WightPit.xls'!ThisWorkbook. main"

and I have to change it to


"Chad Cameron" remove NOT wrote in message
...
Hi All,

I was running Excel 2000. All my macros always refered to excel files as
myfile.xls. We are switching to 2007 and now all files are *.xlsx or xlsm
or xlsb blah blah blah.

How should I change my coding? Do I hard code in the file name as
myfile.xlsm? What happens if the Excel 2010 uses *.xlsmm or somthing
stupid like that. Then do I recode everything again?

There has to be an easier way.

Thanks
Chad



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Coding Etiquette

hmm apprently Ctrl + Enter sends the posts. Here is the rest of my prior
post

Application.Run "'SLOPE_MONITORING_4XX_WightPit.xlsm'!ThisWorkbook .main"


"Chad Cameron" remove NOT wrote in message
...
Hi All,

I was running Excel 2000. All my macros always refered to excel files as
myfile.xls. We are switching to 2007 and now all files are *.xlsx or xlsm
or xlsb blah blah blah.

How should I change my coding? Do I hard code in the file name as
myfile.xlsm? What happens if the Excel 2010 uses *.xlsmm or somthing
stupid like that. Then do I recode everything again?

There has to be an easier way.

Thanks
Chad



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Coding Etiquette

If your files are similarly named in 2003- / 2007+, except for extension,
you could do soemthing like this -

dim sMacro as string

sMacro = "'my File.xls" ' note first character apostrophe
if val(application.version) =12 then
sMacro = sMacro & "m"
end if
sMacro = sMacro & "!myModule.myMacro"

application.run sMacro

In passing, you have "Workbook.Main", in general best to keep code in the
ThisWorkbook module to a minimum, limited to Workbook events only. Suggest
put "main" in a normal module

Regards,
Peter T



"Chad Cameron" remove NOT wrote in message
...
Hi All,

I was running Excel 2000. All my macros always refered to excel files as
myfile.xls. We are switching to 2007 and now all files are *.xlsx or xlsm
or xlsb blah blah blah.

How should I change my coding? Do I hard code in the file name as
myfile.xlsm? What happens if the Excel 2010 uses *.xlsmm or somthing
stupid like that. Then do I recode everything again?

There has to be an easier way.

Thanks
Chad



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Coding Etiquette

Thanks Peter,

"Peter T" <peter_t@discussions wrote in message
...
If your files are similarly named in 2003- / 2007+, except for extension,
you could do soemthing like this -

dim sMacro as string

sMacro = "'my File.xls" ' note first character apostrophe
if val(application.version) =12 then
sMacro = sMacro & "m"
end if
sMacro = sMacro & "!myModule.myMacro"

application.run sMacro

In passing, you have "Workbook.Main", in general best to keep code in the
ThisWorkbook module to a minimum, limited to Workbook events only. Suggest
put "main" in a normal module

Regards,
Peter T



"Chad Cameron" remove NOT wrote in message
...
Hi All,

I was running Excel 2000. All my macros always refered to excel files as
myfile.xls. We are switching to 2007 and now all files are *.xlsx or
xlsm or xlsb blah blah blah.

How should I change my coding? Do I hard code in the file name as
myfile.xlsm? What happens if the Excel 2010 uses *.xlsmm or somthing
stupid like that. Then do I recode everything again?

There has to be an easier way.

Thanks
Chad





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
programming etiquette Brad Excel Programming 2 March 18th 09 01:57 PM
Newcomers' Newsgroup Etiquette Zone[_2_] Excel Programming 0 December 29th 06 11:38 PM
Forum Etiquette Gary L Brown Excel Discussion (Misc queries) 0 January 20th 06 07:37 PM
Chip Pearson's Forum Etiquette Gary L Brown New Users to Excel 0 January 20th 06 07:22 PM
Etiquette for hyperlinks greg7468 Excel Discussion (Misc queries) 3 July 1st 05 01:02 PM


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