Avatar of Vivek Sethia
Vivek Sethia
 asked on

doc save _ vba

save a word doc using a vba.

the doc saved should not contain my code

the doc should be save in a new/desired folder

every time i run the code it should save a new version
VBAMicrosoft Word

Avatar of undefined
Last Comment
Joe Howard

8/22/2022 - Mon
Vivek Sethia

ASKER
still waiting
Joe Howard

What have you tried?
Vivek Sethia

ASKER
ActiveDocument.SaveAs2 FileName:="vivek"

The problem is that it is saving the file along with the code. Hence i would want the doc to be saved in the desired folder and only a word doc.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Joe Howard

Please try:
application.displayalerts=false
ActiveDocument.SaveAs2 FileName:="vivek", FileFormat:=wdFormatXMLDocument
application.displayalerts=true

Open in new window

Vivek Sethia

ASKER
- Should also define a path, inorder to save the doc in the desired folder

- The Fileformat should be docx right?
ASKER CERTIFIED SOLUTION
Joe Howard

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Vivek Sethia

ASKER
hi,

I am not able to unbold my lines

Current Use

'start new line after table'

myRange.EndOf wdStory, wdMove
myRange.InsertAfter "   " & vbCr
myRange.InsertAfter "General Terms And conditions" & vbCr
myRange.InsertAfter "   " & vbCr

'removing bold font
Selection.TypeText Text:="General Terms And conditions"
Selection.Font.Bold = False
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Vivek Sethia

ASKER
please help
Vivek Sethia

ASKER
Some Error

Code Used:

Dim filename As String
Application.DisplayAlerts = False
ActiveDocument.SaveAs2 filename:="C:\Users\Vivek\Documents\saving workbook\" & TBox10.Value & ".docx", Fileformat:=wdFormatXMLDocument
Application.DisplayAlerts = True
Joe Howard

What is the error?

try
Application.DisplayAlerts = False
ActiveDocument.SaveAs2 FileName:="C:\Users\Vivek\Documents\saving workbook\" & TBox10.Value & ".docx", Fileformat:=wdFormatXMLDocument
Application.DisplayAlerts = True 

Open in new window

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Vivek Sethia

ASKER
Error is :

this is not a valid file name
Vivek Sethia

ASKER
Problem solved.

The Filename was Savingworkbook and Not Saving Workbook
Joe Howard

The original question was not solved by you!
You made a mistake which you corrected, but it has nothing to do with the solution which I gave in answers:
ID: 42455135
ID: 42457080
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.