Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
rju rju is offline
external usenet poster
 
Posts: 1
Default Question AND my 1st positive contribution

OK, although I originally wrote the following for VBA/Word it also works
in VBA/Excel...

GOAL:
I want to save a file based on specific fields/cells automatically with
the neumonic "LastNameFirstName.doc(or.xls)...

SOLUTION:the following code works...

Dim strMessage As String, strTitle As String
Dim Response As Long
Dim X As String
Dim filename As String
'Dim ObjWord As Word.Application
'Set ObjWord = New Word.Application
'MsgBox ActiveDocument.Bookmarks.Count
ActiveDocument.Bookmarks("LastName").Select
X = Selection
ActiveDocument.Bookmarks("FirstName").Select
Y = Selection
strTitle = "Bookmark Value 1"
strMessage = "" & X & ""
'Response = MsgBox(strMessage, vbOKOnly + vbCritical, strTitle)
strTitle = "Bookmark Value 2"
strMessage = "" & Y & ""
'Response = MsgBox(strMessage, vbOKOnly + vbCritical, strTitle)
filename = X + Y + ".doc"
strTitle = "File Name to Save As"
strMessage = "" & filename & ""
'Response = MsgBox(strMessage, vbOKOnly + vbCritical, strTitle)
ChangeFileOpenDirectory "C:\BCGprograms\TestFiles2\"
ActiveDocument.SaveAs filename:="" & filename & "",
FileFormat:=wdFormatDocument, _
LockComments:=False, Password:="", AddToRecentFiles:=True,
WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False,
SaveAsAOCELetter:= _
False

(note that I commented out the MsgBoxs'...they were there to help me
along...)

My ultimate goal is to have a folder automatically created instead of
being put in 'TestFiles2'...

I've tried the following:

MkDir "C:\BCGprograms\Clients\"" & filename & ""\"

but it creates a folder called 'filename'...

I thought using the same logic that created the new document name
wouldnalso work in creating the new folder...wrongo...thoughts or
suggestions would be appreciated.

Thanks,
Ron


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Question AND my 1st positive contribution

if you use the following:

MkDir "C:\BCGprograms\Clients\" & filename & "\"

the new folder is created...hope this helps somebody.

Ro

--
Message posted from http://www.ExcelForum.com

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
How to calcuate 6 variable's contribution towards a fixed sum??? Alexander Excel Discussion (Misc queries) 2 April 20th 10 09:46 AM
Subtracting positive amts from negative and positive from positive bwbmom Excel Worksheet Functions 3 February 12th 10 03:15 PM
NPV of cashflows to assess contribution to a joint venture ExcelMonkey Excel Worksheet Functions 2 November 20th 07 12:14 AM
Percent Contribution JR573PUTT Excel Discussion (Misc queries) 2 August 17th 06 06:35 PM
How to calculate pension contribution on salary? pgruening Excel Discussion (Misc queries) 4 September 7th 05 09:28 PM


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