Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-08-2017, 05:59 AM
rosscortb rosscortb is offline How do I use as Save As to take the name from a text and change the file path? Windows XP How do I use as Save As to take the name from a text and change the file path? Office 2010 32bit
Novice
How do I use as Save As to take the name from a text and change the file path?
 
Join Date: May 2014
Posts: 17
rosscortb is on a distinguished road
Default How do I use as Save As to take the name from a text and change the file path?


Hello

I have some code that when run the save as box shows and the file name which is the employee name entered in the text field box by the user. For example. Joe Bloggs contract.docm

This bit is fine. But how do I get it so it shows the name but with a different folder location.
So at the moment the word doc is opened from here -H:\HR\Reward & Shared Services\Shared Services Only\1 ~ Starters\3 ~ Contract Templates\DB Templates

but when it's completed I want it to be saved in this location- H:\HR\Reward & Shared Services\Shared Services Only\1 ~ Starters\5 ~ Offers Sent\2017 Offer of Employment Sent

But with the employees name.


Code:
  Dim fileName As String
    fileName = txtEmployeeName.Value & "Contract"
    With Dialogs(wdDialogFileSaveAs)
      .name = fileName
      .Show
     End With
End Sub
Thanks

Ross
Reply With Quote
  #2  
Old 05-08-2017, 06:25 AM
macropod's Avatar
macropod macropod is offline How do I use as Save As to take the name from a text and change the file path? Windows 7 64bit How do I use as Save As to take the name from a text and change the file path? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Simply add the path to the .Name parameter:
Code:
Dim fileName As String
Const strPath as String = "H:\HR\Reward & Shared Services\Shared Services Only\1 ~ Starters\5 ~ Offers Sent\2017 Offer of Employment Sent\"
fileName = txtEmployeeName.Value & "Contract"
With Dialogs(wdDialogFileSaveAs)
  .Name = strPath & fileName
  .Show
End With
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-08-2017, 06:50 AM
rosscortb rosscortb is offline How do I use as Save As to take the name from a text and change the file path? Windows XP How do I use as Save As to take the name from a text and change the file path? Office 2010 32bit
Novice
How do I use as Save As to take the name from a text and change the file path?
 
Join Date: May 2014
Posts: 17
rosscortb is on a distinguished road
Default

Thanks. You're the best.

Just learning. Code is tough at times.
Reply With Quote
  #4  
Old 03-08-2018, 02:39 AM
rosscortb rosscortb is offline How do I use as Save As to take the name from a text and change the file path? Windows XP How do I use as Save As to take the name from a text and change the file path? Office 2010 32bit
Novice
How do I use as Save As to take the name from a text and change the file path?
 
Join Date: May 2014
Posts: 17
rosscortb is on a distinguished road
Default

Hello,

I have been using the above code in my document and in other documents and it is working fine. However, even though it works in others in now seems to be not working in my contract document, the only thing I have done different is change the strPath to be saved in the 2018 folder instead of the 2017 one.

So the code now is
Code:
Dim fileName As String
Const strPath As String = "H:\HR\Reward & Shared Services\Shared Services Only\1 ~ Starters\5 ~ Offers Sent\2018 Offer of Employment Sent"
fileName = txtLastName.Value & "," & txtFirstName.Value & " - Contract"
With Dialogs(wdDialogFileSaveAs)
  .Name = strPath & fileName
  .Show

 
End With
What happens now is instead of the save as Dialog popping up and displaying LastName,FirstName- contract, it says 2018 Offer of Employment Sent LastName.FirstName -contract

Also, it doesn't save in the strPath but one folder before so
H:\HR\Reward & Shared Services\Shared Services Only\1 ~ Starters\5 ~ Offers Sent

Regards

Ross
Reply With Quote
  #5  
Old 03-08-2018, 04:23 AM
macropod's Avatar
macropod macropod is offline How do I use as Save As to take the name from a text and change the file path? Windows 7 64bit How do I use as Save As to take the name from a text and change the file path? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by rosscortb View Post
the only thing I have done different is change the strPath to be saved in the 2018 folder instead of the 2017 one
You've actually changed more than that - you've changed what you're supplying for the filename, too. You previously had:
fileName = txtEmployeeName.Value & "Contract"
You now have:
fileName = txtLastName.Value & "," & txtFirstName.Value & " - Contract"
Not that that has anything to do with the error. What is causing the error is that you have also deleted the terminating '\' from the filepath, which should end with:
2018 Offer of Employment Sent\"
not just:
2018 Offer of Employment Sent"
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 03-08-2018, 04:30 AM
rosscortb rosscortb is offline How do I use as Save As to take the name from a text and change the file path? Windows XP How do I use as Save As to take the name from a text and change the file path? Office 2010 32bit
Novice
How do I use as Save As to take the name from a text and change the file path?
 
Join Date: May 2014
Posts: 17
rosscortb is on a distinguished road
Default

I have changed a little bit more, you're right but with the little I know I knew that wasn't the issue.

Thanks for your help. Worked a treat.

Ross
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I use as Save As to take the name from a text and change the file path? Turn OFF auto-adding file path as default alternative text for inserted objects Sergey SPb Drawing and Graphics 7 04-24-2017 11:25 PM
Word for Mac 2011: Change default open/save file locations? cglenn Word 0 06-01-2015 10:34 AM
How do I use as Save As to take the name from a text and change the file path? Change old path to new path (batch) NobodysPerfect Word VBA 2 08-14-2014 10:09 PM
How do I use as Save As to take the name from a text and change the file path? How to change save location and file to print name change? albertc Excel Programming 1 05-13-2012 07:05 PM
How do I use as Save As to take the name from a text and change the file path? Word Macro: Save file as text with current file name jabberwocky12 Word VBA 2 10-22-2010 12:23 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:17 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft