Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 12-16-2015, 12:58 AM
gazeranco gazeranco is offline VBA FileCopy Source: problem Windows 7 64bit VBA FileCopy Source: problem Office 2010 64bit
Novice
 
Join Date: Dec 2015
Posts: 5
gazeranco is on a distinguished road
Question Roaming Template Folder Help

Hey All,

New here so welcome to me, and thanks for having me!

I did a quick search to no avail. I use some CAD software and it produces lists for me in .xsr format, not really sure what that is but once done I open them with word, fix the formatting and then save as a .doc.

I recorded a macro to do this for me automatically, but the first issue I had was it was calling everyfile the same name. So I setup a variable/method to get the current file name, but it always uses the same name and its not the corrrect name.

It always saves the file as "templates.doc" in "C:\users\me\AppData\Roaming\Microsoft\Templates\T emplates.doc"

instead of where the file really is (on my desktop in a folder) and its real name (not template)

Any ideas? Code below!

Code:
Sub Format()
'
' Format Macro
' Report Format
'
    Dim fso As New FileSystemObject
    myPath = ThisDocument.Path
    myName = fso.GetBaseName(myPath)
    
    With Selection.PageSetup
        .LineNumbering.Active = False
        .Orientation = wdOrientPortrait
        .TopMargin = CentimetersToPoints(1.27)
        .BottomMargin = CentimetersToPoints(1.27)
        .LeftMargin = CentimetersToPoints(1.27)
        .RightMargin = CentimetersToPoints(1.27)
        .Gutter = CentimetersToPoints(0)
        .HeaderDistance = CentimetersToPoints(1.25)
        .FooterDistance = CentimetersToPoints(1.25)
        .PageWidth = CentimetersToPoints(21)
        .PageHeight = CentimetersToPoints(29.7)
        .FirstPageTray = wdPrinterDefaultBin
        .OtherPagesTray = wdPrinterDefaultBin
        .SectionStart = wdSectionNewPage
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .VerticalAlignment = wdAlignVerticalTop
        .SuppressEndnotes = False
        .MirrorMargins = False
        .TwoPagesOnOne = False
        .BookFoldPrinting = False
        .BookFoldRevPrinting = False
        .BookFoldPrintingSheets = 1
        .GutterPos = wdGutterPosLeft
    End With

    Selection.WholeStory
    Selection.Font.Size = 10
    Selection.Font.Name = "Courier New"
    ChangeFileOpenDirectory (myPath)
    ActiveDocument.SaveAs2 fileName:=(myName), FileFormat:= _
        wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _
        True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _
        False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
        SaveAsAOCELetter:=False, CompatibilityMode:=0
End Sub
Reply With Quote
 

Tags
filecopy, vba, xml



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot open the source object Satish1985 Excel 0 02-06-2014 08:32 PM
VBA FileCopy Source: problem Create DDL from Excel source BradleyS Word 1 01-30-2013 10:58 PM
Cannot find source of overallocation nesskramer Project 3 06-29-2012 08:46 AM
VBA FileCopy Source: problem editing source formatting urboyfriend Word 1 09-22-2011 02:43 AM
Installation Source Corrupted browneyes Office 1 01-23-2006 02:33 PM

Other Forums: Access Forums

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


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft