Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
How write Macro to save worksheet to a RELATIVE address
I have recorded a Macro to save a worksheet. Then I edited the macro to
change the ABSOLUTE file/address to a relative address (I want to save the files in the same folder as the Excel program being run Nb It will run on many different PCs), but the results seem 'unpreditable', sometimes when it runs it writes them to the correct place and sometimes to 'MyDocument'? Any ideas gratefully appreciated. My code is as follows: Sub Macro2() ' ActiveWorkbook.Save MsgBox "Note: The current Spreadsheet has been automatically saved .. as the name will now be changed by the program." ' ' Sheets("meter_readings.xml").Select ActiveWorkbook.SaveAs Filename:= _ "meter_readings.xml" _ , FileFormat:=xlUnicodeText, CreateBackup:=False Sheets("meter_readings.html").Select Range("A1:B10").Select Range("B10").Activate ActiveWorkbook.PublishObjects.Add(xlSourceRange, _ "meter_readings.html" _ , "meter_readings.html", "$A$1:$B$10", xlHtmlStatic, "meter_readings_19233", "" _ ).Publish (True) ' MsgBox "Note: Both files have now been saved to the current subdirectory. The Spreadsheet WILL now be closed without further saving ... (as the name has been changed by the program)" ' Workbooks("meter_readings.xml").Close SaveChanges:=False End Sub -- Thanks ... Barry |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how do I write a request to 'Save As' Macro | Excel Discussion (Misc queries) | |||
How do I avoid excel change absolute address to relative address | Excel Discussion (Misc queries) | |||
How to write macro that selects relative locations | Excel Worksheet Functions | |||
what is difference between absolute address and relative address? | Excel Discussion (Misc queries) | |||
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? | Excel Worksheet Functions |