Replacing file name



My query is about a portion of my vbscript, in which i am trying to
replace the filename that i save in excel file.

FirstFile= ProjectDoc.GetFirstSourceFile()

This function gives the drive+path+file name of the source file in my
db. I use this code in the begining of my script

Afterwards ,In my script the strings of this source file are exported
to an excel file.

If i print the path of this FirstFile the result will be.

E:\code\Properties\UltResComplexQueryUI.resx

At the end of the script i want to save that excel file according to
the name of the source file i-e

UltResComplexQueryUI

to save an excel file in vbscript i use the following code.

objexcel.ActiveWorkbook.SaveAs("c:\Documents and Settings\nakhan
\Desktop\UltResComplexQueryUI
..xls")

This is all manual typing.

Now there are 3-5 source files in my db. which are exported to
different excel files, each of which has to be saved according to the
name of its source file.

i want my script to pick UltResComplexQueryUI
from
FirstFile=E:\code\Properties\UltResComplexQueryUI.resx

and save it
in
(This position) objexcel.ActiveWorkbook.SaveAs"c:\DocumentsandSettings
\nakhan\Desktop\UltResComplexQueryUI
..xls")

automatically. And i want this to happen with all the rest of source
files.

Now to get UltResComplexQueryUI from E:\code\Properties
\UltResComplexQueryUI.resx

I use the mid function i-e

FirstFile=mid(FirstFile,20,20) `20 is the position of U and
next 20 is the length.

The result will be FirstFile=UltResComplexQueryUI

now when i write

objexcel.ActiveWorkbook.SaveAs"c:\DocumentsandSettings\nakhan\Desktop
\FirstFile( or & FirstFile).xls")

it doesnt replace FirstFile

it saves the excel file as FirstFile.xls.

Please Help! i think instr function can be used but i dont know how to
use it.


.



Relevant Pages

  • Re: Replacing file name
    ... replace the filename that i save in excel file. ... This function gives the drive+path+file name of the source file in my ... If i print the path of this FirstFile the result will be. ... For Each sKey In dicRepl.Keys ...
    (microsoft.public.scripting.vbscript)
  • Re: Replacing file name
    ... replace the filename that i save in excel file. ... Afterwards,In my script the strings of this source file are ... If i print the path of this FirstFile the result will be. ... I would agree with ekkehard on using the FSO's path parsing methods. ...
    (microsoft.public.scripting.vbscript)
  • Import data from Word
    ... I use an Excel file as source file to create WORD mail merged documents in a ... table format where users need to complete some blanks. ... individual word files back to the source file where field columns are set up ...
    (microsoft.public.excel.worksheet.functions)
  • How to create a macro for this?
    ... that eventually spools an Excel file. ... This spool file is the source file for a total report (destination ... it can only updates the values if I also open the source file. ...
    (microsoft.public.excel.programming)
  • RE: AD-Users to contacts
    ... I've written a script that takes in input the data from a "well formatted" ... excel file that show the result of each creation. ... - Uppercase letters will be substituted whit lowercase letters ... users in formation from the old directory, the first part of the job). ...
    (microsoft.public.windows.server.scripting)

Loading