2013-01-23 44 views
4

我使用VBa代碼和用戶窗體創建模板...然後將其保存爲dotm(宏啓用模板)。我想打開模板,使用界面在文檔中進行更改,然後將文檔保存爲docx,但沒有引用模板/代碼,因爲當我打開docx並打開visual basic時,我可以找到代碼。將文檔另存爲.docx而不使用VBA代碼

誰能幫助我?我知道這可能是一個愚蠢的問題,但我新:D,並找不到答案。

謝謝 這是我的代碼從界面到退出

Private Sub Sair_Click() 
ActiveDocument.Bookmarks("NomeProj").Range.text = Nomeproj.Value 
ActiveDocument.TablesOfContents(1).Update 
Application.Quit 

End Sub 

回答

1
ActiveDocument.SaveAs FileName:="Test.docx", FileFormat:= _ 
wdFormatXMLDocument, LockComments:=False, Password:="", 
AddToRecentFiles _ 
:=True, WritePassword:="", ReadOnlyRecommended:=False, 
EmbedTrueTypeFonts _ 
:=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _ 
SaveAsAOCELetter:=False 

ActiveDocument.Convert 'Required if not Word 2007 format 

編輯:

的VBA代碼存儲了。如果你想防止這種情況發生,你可以做的最好的事情就是將你的文本移動到一個新的文檔中並保存這個文檔。
簡單的例子,基於一個書籤的存儲:

Option Explicit 

Sub Save_Doc_NoMacros() 

Dim ThisDoc   As Word.Document 
Dim oDoc   As Word.Document 


Set ThisDoc = ActiveDocument 

ThisDoc.Bookmarks("Bookmark1").Select 
Selection.Copy 
Set oDoc = Documents.Add 
Selection.Paste 

oDoc.SaveAs FileName:="U:/Text.docx", FileFormat:=wdFormatDocument 
oDoc.Close 

End Sub 
+0

,我不知道有沒有做錯事,但ActiveDocument.Convert給出一個錯誤,如果我不把我不能在那裏保存文件將會:S任何建議 – user1966363

+0

請檢查更新。 – Trace

相關問題