Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-10-2023, 02:31 AM
Jrod9190 Jrod9190 is offline Macro request help: Save to specific destination on sharepoint Windows 11 Macro request help: Save to specific destination on sharepoint Office 2019
Novice
Macro request help: Save to specific destination on sharepoint
 
Join Date: Jan 2023
Posts: 7
Jrod9190 is on a distinguished road
Lightbulb Macro request help: Save to specific destination on sharepoint

Hello MSO forums! These forums have already been such a great help to my work center and I nearly have the finished product that we need.



Our job uses checklists for everything, it's part of who we are. So far I've had help making our checklist have a macro button to clear the contents after a checklist is filled out; it's very helpful (thanks @gmayor). My next question / request is to see if there's a way to macro saving a copy of the checklist to a certain path on our sharepoint. This would be done after completing a controller completes a checklist, but prior to them wiping the checklist template. I've attached a copy of my current working copy.

Any help would be appreciated, thanks!
Attached Files
File Type: docx Test ELECTRONIC (3).docx (46.0 KB, 5 views)
Reply With Quote
  #2  
Old 02-10-2023, 04:16 PM
BrianHoard BrianHoard is offline Macro request help: Save to specific destination on sharepoint Windows 10 Macro request help: Save to specific destination on sharepoint Office 2019
Advanced Beginner
 
Join Date: Jul 2022
Location: Haymarket, VA USA
Posts: 85
BrianHoard is on a distinguished road
Default

I'm thinking what you are trying to do would be possible, being Office and SharePoint are both Microsoft. Have you tried doing this manually once while recording a macro to see if it records the script for you? It's helped me get started on alot of scripts.
Reply With Quote
  #3  
Old 02-17-2023, 09:08 AM
TheBigBoss TheBigBoss is offline Macro request help: Save to specific destination on sharepoint Windows 10 Macro request help: Save to specific destination on sharepoint Office 2016
Advanced Beginner
 
Join Date: Dec 2016
Posts: 56
TheBigBoss is on a distinguished road
Default

Hi Jrod9190,

I do upload and retrieve files from on our Sharepoint.

I have added the Sharepoint site to our organisation "One Drive". To do so, go to your Sharepoint site then go to the file directory you use in Sharepoint and click on "Add shortcut to One Drive". You should see the directory in your C:/ under "One Drive".

You know have a link to C:/ pointing to your Sharepoint directory. You can now do whatever you want using simple VBA macro. Ensure all staff in your organisation does the same.

In VBA, you should use:
C:\Users" & Environ("UserName") & _
"\OneDrive - MyOrg\MYDIRECTORY\
Reply With Quote
  #4  
Old 02-25-2023, 07:45 PM
Jrod9190 Jrod9190 is offline Macro request help: Save to specific destination on sharepoint Windows 11 Macro request help: Save to specific destination on sharepoint Office 2019
Novice
Macro request help: Save to specific destination on sharepoint
 
Join Date: Jan 2023
Posts: 7
Jrod9190 is on a distinguished road
Default

Quote:
Originally Posted by BrianHoard View Post
I'm thinking what you are trying to do would be possible, being Office and SharePoint are both Microsoft. Have you tried doing this manually once while recording a macro to see if it records the script for you? It's helped me get started on alot of scripts.
Thanks for the record tip. Using it, I was able to get a script that almost works. I think the main issue is that the record feature saves the specific filename (in red below) that I used in the recording. If possible I'd like it to be able to save the current filename to specific folders on our SharePoint. This is the script it produced, could someone help me figure out how to save it as the current filename, if it's even possible? Thanks in advance!

Sub Save_Checklist()
'
' Save_Checklist Macro
'
'
ChangeFileOpenDirectory _
"https://WEBSITE/sites/WEBSITE/WEBSITE/WEBSITE/WEBSITE/Shift%20Changeover%20Brief/Completed%20Checklists/PJ/"
ActiveDocument.SaveAs2 FileName:= _
"https://WEBSITE/sites/WEBSITE/WEBSITE/WEBSITE/WEBSITE/Shift%20Changeover%20Brief/Completed%20Checklists/PJ/Test%20ELECTRONIC%20(3).docx" _
, FileFormat:=wdFormatXMLDocument, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False, CompatibilityMode:=15
End Sub
Reply With Quote
  #5  
Old 02-25-2023, 07:46 PM
Jrod9190 Jrod9190 is offline Macro request help: Save to specific destination on sharepoint Windows 11 Macro request help: Save to specific destination on sharepoint Office 2019
Novice
Macro request help: Save to specific destination on sharepoint
 
Join Date: Jan 2023
Posts: 7
Jrod9190 is on a distinguished road
Default

Quote:
Originally Posted by TheBigBoss View Post
Hi Jrod9190,

I do upload and retrieve files from on our Sharepoint.

I have added the Sharepoint site to our organisation "One Drive". To do so, go to your Sharepoint site then go to the file directory you use in Sharepoint and click on "Add shortcut to One Drive". You should see the directory in your C:/ under "One Drive".

You know have a link to C:/ pointing to your Sharepoint directory. You can now do whatever you want using simple VBA macro. Ensure all staff in your organisation does the same.

In VBA, you should use:
C:\Users" & Environ("UserName") & _
"\OneDrive - MyOrg\MYDIRECTORY\
We don't have an organization One Drive. Instead every employee has their own personal personal drive.
Reply With Quote
  #6  
Old 02-26-2023, 12:20 PM
BrianHoard BrianHoard is offline Macro request help: Save to specific destination on sharepoint Windows 10 Macro request help: Save to specific destination on sharepoint Office 2019
Advanced Beginner
 
Join Date: Jul 2022
Location: Haymarket, VA USA
Posts: 85
BrianHoard is on a distinguished road
Default

Quote:
Originally Posted by Jrod9190 View Post
Thanks for the record tip. Using it, I was able to get a script that almost works. I think the main issue is that the record feature saves the specific filename (in red below) that I used in the recording. If possible I'd like it to be able to save the current filename to specific folders on our SharePoint. This is the script it produced, could someone help me figure out how to save it as the current filename, if it's even possible? Thanks in advance!

Sub Save_Checklist()
'
' Save_Checklist Macro
'
'
ChangeFileOpenDirectory _
"https://WEBSITE/sites/WEBSITE/WEBSITE/WEBSITE/WEBSITE/Shift%20Changeover%20Brief/Completed%20Checklists/PJ/"
ActiveDocument.SaveAs2 FileName:= _
"https://WEBSITE/sites/WEBSITE/WEBSITE/WEBSITE/WEBSITE/Shift%20Changeover%20Brief/Completed%20Checklists/PJ/Test%20ELECTRONIC%20(3).docx" _
, FileFormat:=wdFormatXMLDocument, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False, CompatibilityMode:=15
End Sub

Here's something to try. In this code, we get your current filename as a variable, and also put the output SharePoint path as it's own variable. Note that there is not trailing slash/ in the outputDirectory. I just find this easier to build strings that make sense when I put my own trailing slashes in when I use them.


Finally, I used your code, swapping out some areas with the variables. If this works, it will also let you change the output directory easily since all that is done at the top of the script.
Code:
Sub Save_Checklist()
  
  ' Declare some variables
  Dim outputDirectory As String
  Dim currentFilename As String
  Dim outputNameFull As String
  
  ' Define output name using vars
  currentFilename = ActiveDocument.Name
  outputDirectory = "https://WEBSITE/sites/WEBSITE/WEBSITE/WEBSITE/WEBSITE/Shift%20Changeover%20Brief/Completed%20Checklists/PJ"
  outputNameFull = (outputDirectory & "/" & currentFilename)
  
  ChangeFileOpenDirectory outputDirectory
  
  ActiveDocument.SaveAs2 FileName:=outputNameFull, _
  FileFormat:=wdFormatXMLDocument, LockComments:=False, Password:="", _
  AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
  EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
  :=False, SaveAsAOCELetter:=False, CompatibilityMode:=15

End Sub
Reply With Quote
  #7  
Old 03-22-2023, 07:18 AM
TheBigBoss TheBigBoss is offline Macro request help: Save to specific destination on sharepoint Windows 10 Macro request help: Save to specific destination on sharepoint Office 2016
Advanced Beginner
 
Join Date: Dec 2016
Posts: 56
TheBigBoss is on a distinguished road
Default

Quote:
Originally Posted by Jrod9190 View Post
We don't have an organization One Drive. Instead every employee has their own personal personal drive.
Still, go to your Sharepoint library (usually called "Files")... but go on the web, not Teams. Look for "Add shortcut to OneDrive" and click on it; give it 5-10mn, it will add the directories (with a padlock icon next to it), As long as you have OneDrive, you are good to go, organisation or not.

Use your usual Files Browser and get the path.

Then in VBA, you now have a link in C to do whatever you want in shared environment.

Use Environ to get username.
C:\Users" & Environ("UserName") & _
"\OneDrive\MYDIRECTORY\
Reply With Quote
Reply

Tags
macro, work



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Macro to Save Word File as PDF in Specific Location ekimisme Word VBA 1 06-07-2017 10:40 PM
Macro request help: Save to specific destination on sharepoint Macro: How to get this macro to save to a specific location LOUF Word VBA 1 12-07-2015 06:47 PM
Can't save a Sharepoint document in Windows 10 Gary Tayman Misc 0 08-15-2015 04:22 PM
Macro request help: Save to specific destination on sharepoint Outlook 2010 Macro Save as MSG, Choose Destination, set default filename rslck Outlook 1 06-19-2014 10:16 AM
Office 2010 - Save to Sharepoint Site slice16 Office 0 05-11-2010 06:43 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:43 AM.


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