Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-05-2022, 04:03 AM
elaineAda elaineAda is offline Macro save a form generated from a template Windows XP Macro save a form generated from a template Office 2010
Novice
Macro save a form generated from a template
 
Join Date: Mar 2019
Posts: 25
elaineAda is on a distinguished road
Default Macro save a form generated from a template

Hi


I have this macro for a command button in my template to save a form (word document when i open the template) after completion of the form. But i encountered run time error 4198 when i tried to run this in the word document generated from the template. Any help is appreciated. Thanks.


Code:
Private Sub SaveAsPDF_Click()

With Application.FileDialog(msoFileDialogSaveAs)
.FilterIndex = 3
.Show

If .SelectedItems.Count <> 0 Then
ThisDocument.SaveAs2 .SelectedItems(1), wdFormatDocument
End If
End With

End Sub
Thanks

Last edited by elaineAda; 05-05-2022 at 06:32 AM.
Reply With Quote
  #2  
Old 05-05-2022, 12:25 PM
Italophile Italophile is online now Macro save a form generated from a template Windows 11 Macro save a form generated from a template Office 2021
Expert
 
Join Date: Mar 2022
Posts: 315
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

Code:
ThisDocument
refers to the document that contains the code, which is the template in this case. What you need to use instead is
Code:
ActiveDocument
Reply With Quote
  #3  
Old 05-05-2022, 05:29 PM
elaineAda elaineAda is offline Macro save a form generated from a template Windows XP Macro save a form generated from a template Office 2010
Novice
Macro save a form generated from a template
 
Join Date: Mar 2019
Posts: 25
elaineAda is on a distinguished road
Default

Thanks a lot! It works. But something else happen.

After added in the activeX command button, all my macro cannot work when i open the template to a document, but within the template, all the macros can work.

I then delete the activeX command button and try again, all my macros work.

Any idea why i cannot add in an activeX command button.
I wanted a button in the tempalte, is there any other way beside the activeX command button?
Pl advise me how to go about it. Thanks.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cant save document as docx or doc using macro in Word 2007 staicumihai Word VBA 1 04-27-2018 10:59 AM
Macro save a form generated from a template File will not save as docx. only doc. Library Worker Word 5 01-27-2016 09:40 AM
Macro save a form generated from a template Word 2007 , when I save a .doc or .docx file the file type is showing "Empty" Tomc29 Word 9 06-10-2015 03:04 AM
Macro save a form generated from a template Getting Macro To Work in .docx file on Website Mhangoy Word 6 09-06-2013 06:57 AM
Macro save a form generated from a template Can't Save a file as .docx the_lil Word 5 10-27-2011 08:41 AM

Other Forums: Access Forums

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