Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Can' find error

I have the following macro that works perfect for opening
a txt file.

Workbooks.OpenText Filename:= _
"C:\Path\Report200407JC.txt" _
, Origin:=xlWindows, StartRow:=1,
DataType:=xlFixedWidth, FieldInfo:= _
Array(Array(0, 1), Array(5, 1), Array(10, 1),
Array(15, 1), Array(20, 1), Array(25, 1))

What I want to do is change the month in the name each
month. So I am using;

Dim Mth As String

Mth = "" & Format(DateSerial(Year(Date), Month(Date)
- 1, 1), "yyyymm")

Workbooks.OpenText Filename:= _
"C:\Path\Report & "Mth" & JC.txt" _
, Origin:=xlWindows, StartRow:=1,
DataType:=xlFixedWidth, FieldInfo:= _
Array(Array(0, 1), Array(5, 1), Array(10, 1),
Array(15, 1), Array(20, 1), Array(25, 1))

I would like "Mth" to generate 200407 in Aug so the file
name generated would be Report200407JC.txt

But this always gives me a syntax error. Any ideas where
the error is

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 618
Default Can' find error

Hi Jack

"C:\Path\Report & "Mth" & JC.txt" _
should be
"C:\Path\Report" & Mth & "JC.txt" _

cheers
JulieD

"Jack S." wrote in message
...
I have the following macro that works perfect for opening
a txt file.

Workbooks.OpenText Filename:= _
"C:\Path\Report200407JC.txt" _
, Origin:=xlWindows, StartRow:=1,
DataType:=xlFixedWidth, FieldInfo:= _
Array(Array(0, 1), Array(5, 1), Array(10, 1),
Array(15, 1), Array(20, 1), Array(25, 1))

What I want to do is change the month in the name each
month. So I am using;

Dim Mth As String

Mth = "" & Format(DateSerial(Year(Date), Month(Date)
- 1, 1), "yyyymm")

Workbooks.OpenText Filename:= _
"C:\Path\Report & "Mth" & JC.txt" _
, Origin:=xlWindows, StartRow:=1,
DataType:=xlFixedWidth, FieldInfo:= _
Array(Array(0, 1), Array(5, 1), Array(10, 1),
Array(15, 1), Array(20, 1), Array(25, 1))

I would like "Mth" to generate 200407 in Aug so the file
name generated would be Report200407JC.txt

But this always gives me a syntax error. Any ideas where
the error is



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
Error dialog box meaning and how to find error Jeanne Excel Worksheet Functions 2 September 4th 08 04:59 AM
I cannot find an error in excel Cathie Excel Discussion (Misc queries) 2 August 12th 07 12:31 AM
how to find an error nastech Excel Discussion (Misc queries) 0 July 12th 06 04:59 AM
help with this error-Compile error: cant find project or library JackR Excel Discussion (Misc queries) 2 June 10th 06 09:09 PM
Can' t do a 3d graph in Office XP for Students chiefjay Charts and Charting in Excel 0 September 22nd 05 02:36 PM


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