Welcome to MacForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Excel Macro Difficulties

 
   Macintosh computer (Home) -> Excel RSS
Next:  Autoformat Colors  
Author Message
Aidan Gullickson

External


Since: Feb 12, 2004
Posts: 1



(Msg. 1) Posted: Thu Feb 12, 2004 5:37 pm
Post subject: Excel Macro Difficulties
Archived from groups: microsoft>public>mac>office>excel (more info?)

I am having problems with an Excel macro that was originally written
on a Windows machine. This macro works completely fine on a Windows
computer, but gives back all kinds of error messages on any Mac. Here
is the full text of the macro. Does anyone have any suggestions?
Thanks.

Windows("convert NES headers.xls").Visible = False

' Generate an "Open File" window for the user to select the NES header
files

fNameArray = Application.GetOpenFilename("Text Files (*.txt),
*.txt", MultiSelect:=True)

' Loop through each file and perform a Text to Columns import

For Each fName In fNameArray

Workbooks.OpenText Filename:= _
fName, Origin:= _
xlWindows, StartRow:=1, DataType:=xlDelimited,
TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False,
Semicolon:=False _
, Comma:=True, Space:=False, Other:=False,
FieldInfo:=Array(Array(1, 2), _
Array(2, 2), Array(3, 2), Array(4, 2), Array(5, 2),
Array(6, 2), Array(7, 2), Array(8, 2), _
Array(9, 2))

' Delete the top "comment" row created by the first comment line in
the NES header file

Rows("1:2").Select
Selection.Delete Shift:=xlUp

' Build the spreadsheet filename from the NES header filename: take
current filename minus
' the ".txt" and replace with ".xls"

Dim newfName, position, newfNameandType
position = (fName,".txt")
newfName = Left(fName, position - 1)
newfNameandType = newfName + ".xls"

ActiveWorkbook.SaveAs Filename:=newfNameandType,
FileFormat:=xlNormal

ActiveWindow.Close

Next


MsgBox "Conversion of NES headers complete."

Windows("convert NES headers.xls").Close False

End Sub

 >> Stay informed about: Excel Macro Difficulties 
Back to top
Login to vote
Bob Greenblatt3

External


Since: Oct 09, 2003
Posts: 22



(Msg. 2) Posted: Fri Feb 13, 2004 3:46 pm
Post subject: Re: Excel Macro Difficulties [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

in article 89ff2651.0402121437.2226d5f2.RemoveThis@posting.google.com, Aidan Gullickson
at aidang.RemoveThis@earthlink.net wrote on 2/12/04 5:37 PM:

 > I am having problems with an Excel macro that was originally written
 > on a Windows machine. This macro works completely fine on a Windows
 > computer, but gives back all kinds of error messages on any Mac. Here
 > is the full text of the macro. Does anyone have any suggestions?
 > Thanks.
 >
 > Windows("convert NES headers.xls").Visible = False
 >
 > ' Generate an "Open File" window for the user to select the NES header
 > files
 >
 > fNameArray = Application.GetOpenFilename("Text Files (*.txt),
 > *.txt", MultiSelect:=True)
 >
 > ' Loop through each file and perform a Text to Columns import
 >
 > For Each fName In fNameArray
 >
 > Workbooks.OpenText Filename:= _
 > fName, Origin:= _
 > xlWindows, StartRow:=1, DataType:=xlDelimited,
 > TextQualifier:= _
 > xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False,
 > Semicolon:=False _
 > , Comma:=True, Space:=False, Other:=False,
 > FieldInfo:=Array(Array(1, 2), _
 > Array(2, 2), Array(3, 2), Array(4, 2), Array(5, 2),
 > Array(6, 2), Array(7, 2), Array(8, 2), _
 > Array(9, 2))
 >
 > ' Delete the top "comment" row created by the first comment line in
 > the NES header file
 >
 > Rows("1:2").Select
 > Selection.Delete Shift:=xlUp
 >
 > ' Build the spreadsheet filename from the NES header filename: take
 > current filename minus
 > ' the ".txt" and replace with ".xls"
 >
 > Dim newfName, position, newfNameandType
 > position = (fName,".txt")
 > newfName = Left(fName, position - 1)
 > newfNameandType = newfName + ".xls"
 >
 > ActiveWorkbook.SaveAs Filename:=newfNameandType,
 > FileFormat:=xlNormal
 >
 > ActiveWindow.Close
 >
 > Next
 >
 >
 > MsgBox "Conversion of NES headers complete."
 >
 > Windows("convert NES headers.xls").Close False
 >
 > End Sub

The syntax for getopenfilename is not correct for the Macintosh. Check the
help file for the proper syntax. I think there is also a problem with
multiselect on the Macintosh, so the logic may need to be changed to look at
each file in the directory and only process the text files.

--
Bob Greenblatt [Mac MVP]
bobgreenblattATmsnDOTcom <--fix this before replying
<a rel="nofollow" style='text-decoration: none;' href="http://www.bandlassoc.com" target="_blank">www.bandlassoc.com</a>

 >> Stay informed about: Excel Macro Difficulties 
Back to top
Login to vote
Jim Gordon MVP1

External


Since: Nov 22, 2003
Posts: 229



(Msg. 3) Posted: Fri Feb 20, 2004 2:32 am
Post subject: Re: Excel Macro Difficulties [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi Aidan,

On the Mac, Multi-Select only has one correct setting, which is FALSE. If
you set it to TRUE you will get an error. Here's more info excerpted from
the help file:

On the Macintosh, this string is a list of comma-separated file type codes
(for example, "TEXT,XLA5,XLS4"). Spaces are significant and shouldn't be
inserted before or after the comma separators unless they're part of the
file type code. If omitted, this argument defaults to all file types.

FilterIndex Optional Variant. Windows only (ignored on the Macintosh).
Title Optional Variant. Windows only (ignored on the Macintosh).
ButtonText Optional Variant. Macintosh only (ignored in Windows).
Specifies the text used for the Open button in the dialog box. If this
argument is omitted, the button text is "Open."
MultiSelect The default value is False.


-Jim Gordon
Mac MVP

All responses should be made to this newsgroup within the same thread.
Thanks.

About Microsoft MVPs:
<a rel="nofollow" style='text-decoration: none;' href="http://www.mvps.org/" target="_blank">http://www.mvps.org/</a>

Before posting a "new" topic please be sure to search Google Groups to see
if your question has already been answered.


----------
In article ,
aidang.DeleteThis@earthlink.net (Aidan Gullickson) wrote:


 >
 > I am having problems with an Excel macro that was originally written
 > on a Windows machine. This macro works completely fine on a Windows
 > computer, but gives back all kinds of error messages on any Mac. Here
 > is the full text of the macro. Does anyone have any suggestions?
 > Thanks.
 >
 > Windows("convert NES headers.xls").Visible = False
 >
 > ' Generate an "Open File" window for the user to select the NES header
 > files
 >
 > fNameArray = Application.GetOpenFilename("Text Files (*.txt),
 > *.txt", MultiSelect:=True)
 >
 > ' Loop through each file and perform a Text to Columns import
 >
 > For Each fName In fNameArray
 >
 > Workbooks.OpenText Filename:= _
 > fName, Origin:= _
 > xlWindows, StartRow:=1, DataType:=xlDelimited,
 > TextQualifier:= _
 > xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False,
 > Semicolon:=False _
 > , Comma:=True, Space:=False, Other:=False,
 > FieldInfo:=Array(Array(1, 2), _
 > Array(2, 2), Array(3, 2), Array(4, 2), Array(5, 2),
 > Array(6, 2), Array(7, 2), Array(8, 2), _
 > Array(9, 2))
 >
 > ' Delete the top "comment" row created by the first comment line in
 > the NES header file
 >
 > Rows("1:2").Select
 > Selection.Delete Shift:=xlUp
 >
 > ' Build the spreadsheet filename from the NES header filename: take
 > current filename minus
 > ' the ".txt" and replace with ".xls"
 >
 > Dim newfName, position, newfNameandType
 > position = (fName,".txt")
 > newfName = Left(fName, position - 1)
 > newfNameandType = newfName + ".xls"
 >
 > ActiveWorkbook.SaveAs Filename:=newfNameandType,
 > FileFormat:=xlNormal
 >
 > ActiveWindow.Close
 >
 > Next
 >
 >
 > MsgBox "Conversion of NES headers complete."
 >
 > Windows("convert NES headers.xls").Close False
 >
 > End Sub
 >> Stay informed about: Excel Macro Difficulties 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Excel - Macro's - Can I open Windows Excel file with MAcro's in Excel 2004 for MAc?

EXCEL 2007 macro - I am having a problem in EXCEL 2007 with macros that have worked since EXCEL 98. I am trying to copy data from a spreadsheet and copy it to a line graph. The NEW date for the X axis is in column A and the NEW points for the line graphs are in severa...

Excel Macro Problem - I just upgraded my Mac to Office 2004. I am trying to open some older Excel files that were created on a PC that have Macros in them. The opened fine in Office X. They open fine but when I close the Excel file it says the Excel has unexpectedly quit. It....

Excel Macro Question - Hi- I am trying to record a simple macro that will: - Run the "Text to Column" command on the selected cell - Split the contents of the cell based on the space delimiter - Deliver the results to the selected cell and subsequent cells to the ri...

Excel 2001 to Excel X Macro problems - I'm not an Excel macro expert, but am working with a customer who recently moved from OS 9 to OS X (and from Office 2001 to Office X). He had a spreadsheet in Excel 2001 with some macros that would create an "animation" effect when he clicked a...
   Macintosh computer (Home) -> Excel All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]