Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 06-11-2019, 10:30 AM
wolfgrrl wolfgrrl is offline Sequential numbering across multiple docs Windows 10 Sequential numbering across multiple docs Office 2010
Novice
 
Join Date: May 2019
Posts: 15
wolfgrrl is on a distinguished road
Default

I've got this code working now.



Code:
Private Sub Document_New()
Application.ScreenUpdating = False
Dim InvNum As String
With ThisDocument
  InvNum = .CustomDocumentProperties("InvNum") + 1
  .CustomDocumentProperties("InvNum") = InvNum
  '.Save
End With
With ActiveDocument
  'Update the value stored in the document property
  .CustomDocumentProperties("InvNum") = InvNum
  'Update the fields in the document
  .Fields.Update
End With
Application.ScreenUpdating = True
ActiveDocument.FormFields("ECNNUM").Result = InputBox("Please enter the ECN number. ")
ActiveDocument.Fields.Update
End Sub
I've tried to add this code to force a "Save As" on document_new, but the last place I used this code was on document_open.

Code:
 With Application.Dialogs(wdDialogFileSaveAs)
    .Name = "c:\My Documents\SaveExample.docm"
    .Format = wdFormatXMLDocumentMacroEnabled
    .Show
Is there code that will force a save such as this that will work in document_new? This is the very last step to getting this template to functions as I'd like.

Thank you for all your assistance!
Reply With Quote
  #17  
Old 06-11-2019, 01:27 PM
Charles Kenyon Charles Kenyon is offline Sequential numbering across multiple docs Windows 10 Sequential numbering across multiple docs Office 2016
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,125
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Try

ActiveDocument.Save


It should bring up a save dialog in a new document. This is what it produces in Word 2019.
Reply With Quote
  #18  
Old 06-11-2019, 04:17 PM
macropod's Avatar
macropod macropod is offline Sequential numbering across multiple docs Windows 7 64bit Sequential numbering across multiple docs 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

Try:
Code:
Private Sub Document_New()
Application.ScreenUpdating = False
Dim InvNum As String
With ThisDocument
  InvNum = .CustomDocumentProperties("InvNum") + 1
  .CustomDocumentProperties("InvNum") = InvNum
  .Save
End With
With ActiveDocument
  'Update the value stored in the document property
  .CustomDocumentProperties("InvNum") = InvNum
  'Update the fields in the document
  .FormFields("ECNNUM").Result = InputBox("Please enter the ECN number. ")
  .Fields.Update
End With
Application.ScreenUpdating = True
With Application.Dialogs(wdDialogFileSaveAs)
  .Name = "c:\My Documents\SaveExample.docx"
  .Format = wdFormatXMLDocument
  .Show
End With
End Sub
I note that you commented-out the .Save for the template. Do that and the numbers won't increment unless you tell Word to save the changes to the template when you exit Word. Furthermore, in a multi-user environment, that promotes the duplication of numbers if multiple users are creating these documents at the same time.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #19  
Old 06-12-2019, 04:00 AM
wolfgrrl wolfgrrl is offline Sequential numbering across multiple docs Windows 10 Sequential numbering across multiple docs Office 2010
Novice
 
Join Date: May 2019
Posts: 15
wolfgrrl is on a distinguished road
Default

@macropod,

I copied the code as it was posted. The save command was commented out in the original post

I'll try this new code and see how it works. Thank you!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sequential numbering across multiple docs How do I do a Sequential Numbering? gburya Word VBA 26 07-04-2017 03:29 PM
Sequential numbering across multiple docs Sequential Page Numbering of Multiple Word Docs bobmard Word 8 08-24-2011 08:51 AM
Sequential numbering across multiple docs Editing multiple docs frankdh Word 2 11-02-2010 10:59 AM
Please help with Numbering a document with multiple letters. DJReality213 Office 1 01-15-2010 05:56 PM
Amend footer in multiple word docs? compact Word 2 02-24-2009 09:40 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:36 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